How to use freemarker - 5 common examples

To help you get started, we’ve selected a few freemarker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kaola-fed / foxman / src / helper / render.es6 View on Github external
constructor(settings) {
		this.freemarker = new Freemarker(Object.assign({
			viewRoot: settings.viewRoot,
			options: {
                // sourceEncoding: 'utf-8'
			}
		}, settings));
	}
github ijse / gulp-freemarker / index.js View on Github external
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
github elcarim5efil / fozy / src / engine / freemarker.js View on Github external
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,
          });
        }
      });
    })),
  };
};
github ijse / FED / bin / fed-server.js View on Github external
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;
github kaola-fed / foxman / src / helper / freemarker.es6 View on Github external
constructor({viewRoot}) {
        this.freemarker = new Freemarker({
            root: viewRoot
        });
        this.viewRoot = viewRoot;
    }
    parse(p1, data) {

freemarker

Freemarker integration for NodeJS.

MIT
Latest version published 3 years ago

Package Health Score

46 / 100
Full package analysis

Popular freemarker functions