Update slide template using ejs instead of mustache to reduce similar package dependency

This commit is contained in:
Cheng-Han, Wu 2016-05-29 17:54:24 +08:00
parent c73c32d127
commit 16990e35a2
5 changed files with 101 additions and 89 deletions

View file

@ -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;