From d3ebdb64b2dc7f6a918d8858601d7fb041b58c11 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Tue, 23 Aug 2016 15:31:09 +0100 Subject: [PATCH] precompile the jade partial views --- services/web/app/coffee/infrastructure/Modules.coffee | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/services/web/app/coffee/infrastructure/Modules.coffee b/services/web/app/coffee/infrastructure/Modules.coffee index 2df8907f7e..0dfbf3fa22 100644 --- a/services/web/app/coffee/infrastructure/Modules.coffee +++ b/services/web/app/coffee/infrastructure/Modules.coffee @@ -25,14 +25,14 @@ module.exports = Modules = for module in @modules for view, partial of module.viewIncludes or {} @viewIncludes[view] ||= [] - @viewIncludes[view].push fs.readFileSync(Path.join(MODULE_BASE_PATH, module.name, "app/views", partial + ".jade")) + @viewIncludes[view].push jade.compile(fs.readFileSync(Path.join(MODULE_BASE_PATH, module.name, "app/views", partial + ".jade")), doctype: "html") moduleIncludes: (view, locals) -> - partials = Modules.viewIncludes[view] or [] + compiledPartials = Modules.viewIncludes[view] or [] html = "" - for partial in partials - compiler = jade.compile(partial, doctype: "html") - html += compiler(locals) + for compiledPartial in compiledPartials + d = new Date() + html += compiledPartial(locals) return html moduleIncludesAvailable: (view) ->