Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(settings) {
this.freemarker = new Freemarker(Object.assign({
viewRoot: settings.viewRoot,
options: {
// sourceEncoding: 'utf-8'
}
}, settings));
}
module.exports = function(options) {
if (!arguments.length)
throw new PluginError('gulp-freemarker', 'invoked with no arguments!')
if (!options.viewRoot)
throw new PluginError('gulp-freemarker', 'viewRoot option is mandatory!')
var engine = new Freemarker(options)
return through.obj(function(file, encoding, callback) {
if (file.isNull()){
this.push(file)
return callback()
}
if (file.isBuffer()) {
try{
var config = JSON.parse(file.contents)
}catch(err){
callback(err)
}
engine.render(config.file || config.tpl, config.data, function(err, html, output) {
if (err) return callback(err + output)
file.contents = new Buffer(html || output)
file.path = file.path.replace('.json', '.html') // fixme: feels a bit hacky
module.exports = (option) => {
const fm = new Freemarker(option);
return {
engine: fm,
render: async (tpl, json) => new Promise(((resolve, reject) => {
fm.render(tpl, json, (err, html, output) => {
if (err) {
reject(err);
} else {
resolve({
html,
output,
});
}
});
})),
};
};
notify.on('beforeMock', function(app, opts) {
if(!program.viewRoot) return ;
var viewRoot = join(serv.path, program.viewRoot);
var freemarker = new Freemarker({
viewRoot: viewRoot
});
app.use(function(req, res, next) {
res.render = (function(view, data, done) {
var _this = this;
freemarker.render(view, data, function(err, data, out) {
_this.end(data||out);
done && done(err, data||out);
});
}).bind(res);
next();
});
app.render = freemarker.render;
constructor({viewRoot}) {
this.freemarker = new Freemarker({
root: viewRoot
});
this.viewRoot = viewRoot;
}
parse(p1, data) {