1 | var fs = require('fs'),
|
2 | path = require('path'),
|
3 | Handlebars = require('handlebars'),
|
4 | pageTemplate = Handlebars.compile(fs.readFileSync(path.join(__dirname,'../tpl/PreviewDocument.hbs')).toString());
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | Handlebars.registerHelper('helperMissing', function(options) {
|
12 | var varName = options.name;
|
13 | return varName;
|
14 | });
|
15 |
|
16 | function PreviewDocument(){
|
17 | this.components = [];
|
18 | }
|
19 |
|
20 | PreviewDocument.prototype.addComponent = function(component) {
|
21 | this.components.push(component);
|
22 | };
|
23 |
|
24 | PreviewDocument.prototype.render = function() {
|
25 |
|
26 | return pageTemplate({
|
27 | component: this.components[0],
|
28 | html: this.components[0].render(),
|
29 | cacheBust: (new Date()).getTime()
|
30 | });
|
31 | };
|
32 |
|
33 | module.exports = PreviewDocument; |
\ | No newline at end of file |