From 8d0186532f78dc44f3084474744f36c39bd445d5 Mon Sep 17 00:00:00 2001 From: James Allen Date: Tue, 4 Apr 2017 10:46:46 +0100 Subject: [PATCH] Properly pass project data as JSON and then parse it --- services/web/app/views/project/list.pug | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/services/web/app/views/project/list.pug b/services/web/app/views/project/list.pug index aad484a75e..ddf80a0b5f 100644 --- a/services/web/app/views/project/list.pug +++ b/services/web/app/views/project/list.pug @@ -3,15 +3,11 @@ extends ../layout block content //- We need to do .replace(/\//g, '\\/') do that '' -> '<\/script>' //- and doesn't prematurely end the script tag. - - + script#data(type="application/json"). + !{JSON.stringify({ projects: projects, tags: tags, notifications: notifications }).replace(/\//g, '\\/')} script(type="text/javascript"). - window.data = { - projects: !{JSON.stringify(projects).replace(/\//g, '\\/')}, - tags: !{JSON.stringify(tags).replace(/\//g, '\\/')}, - notifications: !{JSON.stringify(notifications).replace(/\//g, '\\/')} - }; + window.data = JSON.parse($("#data").text()); window.algolia = { institutions: { app_id: '#{algolia_app_id}',