Skip to content

Commit

Permalink
rendering to a main layout
Browse files Browse the repository at this point in the history
  • Loading branch information
jdan committed Oct 6, 2012
1 parent 5909e52 commit ef217ad
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/render.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
var fs = require('fs'),
mustache = require('mustache');
mustache = require('mustache'),
md = require('node-markdown').Markdown;

exports.render = function(json) {
var slides = [];
json.slides.forEach(function(v, i) {
fs.readFile('templates/_' + v.type + '.mustache', 'utf8', function(err, data) {
if (err) throw err;
console.log(mustache.render(data, v));
if (v.type == 'text')
v.content = md(v.content.replace(/>>/g,'</p><p>'));

slides[i] = mustache.render(data, v);
});
});
}

fs.readFile('templates/layout.mustache', 'utf8', function(err, data) {
if (err) throw err;
fs.writeFile('output.html', mustache.render(data, { slides: slides }));
});
};
10 changes: 10 additions & 0 deletions templates/layout.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<html>
<head>
<title>Test</title>
</head>
<body>
{{#slides}}
{{{.}}}
{{/slides}}
</body>
</html>

0 comments on commit ef217ad

Please sign in to comment.