From 16990e35a209704aa7538bb3231085c11da05b06 Mon Sep 17 00:00:00 2001 From: Cheng-Han, Wu Date: Sun, 29 May 2016 17:54:24 +0800 Subject: Update slide template using ejs instead of mustache to reduce similar package dependency --- lib/response.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'lib/response.js') diff --git a/lib/response.js b/lib/response.js index 062bc5db..873dfe4e 100644 --- a/lib/response.js +++ b/lib/response.js @@ -18,7 +18,6 @@ var models = require("./models"); //slides var md = require('reveal.js/plugin/markdown/markdown'); -var Mustache = require('mustache'); //reveal.js var opts = { @@ -244,7 +243,6 @@ function showPublishNote(req, res, next) { function renderPublish(data, res) { var template = config.prettypath; var options = { - url: config.serverurl, cache: !config.debug, filename: template }; @@ -512,14 +510,27 @@ function showPublishSlide(req, res, next) { var render = function (res, title, markdown) { var slides = md.slidify(markdown, opts); - res.end(Mustache.to_html(opts.template, { + var template = config.slidepath; + var options = { + cache: !config.debug, + filename: template + }; + var compiled = ejs.compile(fs.readFileSync(template, 'utf8'), options); + var html = compiled({ url: config.serverurl, title: title, theme: opts.theme, highlightTheme: opts.highlightTheme, slides: slides, options: JSON.stringify(opts.revealOptions, null, 2) - })); + }); + var buf = html; + res.writeHead(200, { + 'Content-Type': 'text/html; charset=UTF-8', + 'Cache-Control': 'private', + 'Content-Length': buf.length + }); + res.end(buf); }; module.exports = response; -- cgit v1.2.3