Last active
August 29, 2015 14:25
-
-
Save wangzuo/d5bd8d620b22f4baaaa9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var path = require('path'); | |
var mustache = require('mustache'); | |
var onebox = require('onebox'); | |
// custom render method for preview | |
var preview = onebox({ | |
render: function(engine, data, cb) { | |
var tpath = path.join(__dirname, 'templates', engine+'.mustache'); | |
fs.readFile(tpath, function(err, buf) { | |
if(err) return cb(err); | |
var template = buf.toString(); | |
var html = mustache.render(template, data); | |
cb(null, html); | |
}); | |
} | |
}); | |
var link = 'http://github.com/wangzuo/onebox/issues/1'; | |
preview(link, function(err, html) { | |
if(err) throw err; | |
console.log(html); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment