summaryrefslogtreecommitdiff
path: root/lib/response.js
diff options
context:
space:
mode:
authorCheng-Han, Wu2016-05-29 17:54:24 +0800
committerCheng-Han, Wu2016-05-29 17:54:24 +0800
commit16990e35a209704aa7538bb3231085c11da05b06 (patch)
tree0e7a6ed0534559b4ee5cab6bb5e214776b3d9825 /lib/response.js
parentc73c32d12759a44c46b18548e7d1ef3fc1678473 (diff)
Update slide template using ejs instead of mustache to reduce similar package dependency
Diffstat (limited to 'lib/response.js')
-rw-r--r--lib/response.js19
1 files changed, 15 insertions, 4 deletions
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;