How to use the handlebars.templates function in handlebars

To help you get started, we’ve selected a few handlebars 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 zulip / zulip / frontend_tests / zjsunit / render.js View on Github external
exports.compile_template = function (name) {
    var included_fns = exports.find_included_partials(name);

    _.each(included_fns, function (fn) {
        exports.compile_template(fn);
    });

    if (Handlebars.templates === undefined) {
        Handlebars.templates = {};
    }

    if (_.has(Handlebars.template, name)) {
        // we already compile the template
        return;
    }

    var file = exports.template_finder.get(name);
    var data = fs.readFileSync(file.url).toString();
    Handlebars.templates[name] = Handlebars.compile(data);
};
github mattacular / grunt-handlebars-compiler / test / expected / helloWorld-exportCommonJSWithReturnTemplates.compiled.js View on Github external
var Handlebars = require('handlebars');
var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
templates['helloWorld'] = template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var helper, alias1=helpers.helperMissing, alias2="function", alias3=container.escapeExpression;

  return "\n\n	\n		<div>Hello world! "
    + alias3(((helper = (helper = helpers.message || (depth0 != null ? depth0.message : depth0)) != null ? helper : alias1),(typeof helper === alias2 ? helper.call(depth0,{"name":"message","hash":{},"data":data}) : helper)))
    + "</div>\n	\n";
},"useData":true});
module.exports = templates;
github nicjansma / node-handlebars-precompiler / test / expected / commonjs.js View on Github external
var Handlebars = require("handlebars");  var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
templates['comments/form'] = template({"compiler":[6,"&gt;= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
  var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
  return "<form method="\&quot;get\&quot;">"
    + escapeExpression(((helper = (helper = helpers.content || (depth0 != null ? depth0.content : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"content","hash":{},"data":data}) : helper)))
    + "</form>";
},"useData":true});
templates['user/listItem'] = template({"compiler":[6,"&gt;= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
  var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
  return "<li class="\&quot;user\&quot;">"
    + escapeExpression(((helper = (helper = helpers.content || (depth0 != null ? depth0.content : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"content","hash":{},"data":data}) : helper)))
    + "</li>";
},"useData":true});
module.exports = templates;
github mattacular / grunt-handlebars-compiler / test / expected / helloWorld-exportCommonJS.compiled.js View on Github external
var Handlebars = require('handlebars');
var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
templates['helloWorld'] = template({"compiler":[7,"&gt;= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var helper, alias1=helpers.helperMissing, alias2="function", alias3=container.escapeExpression;

  return "\n\n	\n		<div>Hello world! "
    + alias3(((helper = (helper = helpers.message || (depth0 != null ? depth0.message : depth0)) != null ? helper : alias1),(typeof helper === alias2 ? helper.call(depth0,{"name":"message","hash":{},"data":data}) : helper)))
    + "</div>\n	\n";
},"useData":true});
github cliqz-oss / browser-core / modules / mobile-ui / sources / window.es View on Github external
init() {
    Object.keys(helpers).forEach(function (helperName) {
      Handlebars.registerHelper(helperName, helpers[helperName]);
    });
    window.CLIQZ.templates = Handlebars.templates = templates;
    Handlebars.partials = templates;
    Object.keys(VIEWS).forEach(view => UI.VIEWS[view] = new (VIEWS[view])() );


  	window.CLIQZ.UI = UI;
  	window.CLIQZ.UI.init();
  }
github ryanramage / question-flow / lib / ui / topics.js View on Github external
_.each(data.rows, function(row) {
                var topicDoc = row.doc;
                topicIds.push(topicDoc._id);
                userIds.push(topicDoc.user);
                topicDoc.timestamp_formatted = moment(topicDoc.timestamp).fromNow();
                topicDoc.user_hash = common.userToHash(topicDoc.user);
                topicDoc.gravatar_url = common.getGravatar({name: topicDoc.user}, 32);
                topicDoc.short_text = topicDoc.text.substring(0, 200);
                if (topicDoc.text.length > 200) topicDoc.short_text += '...';

                $('.topics').append(handlebars.templates['topic-row.html'](topicDoc, {}));
            });
        }
github adaptlearning / adapt-contrib-media / js / popup.js View on Github external
define(function(require) {
	
	var Handlebars = require('handlebars');
	
	var Popup = Backbone.View.extend( {
		
		className: "pop-up",
		parent: "#wrapper",
		template: Handlebars.templates.popup,
		
		initialize: function(){
			this.$parent = $(this.parent);
			_.bindAll(this, "move", "stop");
			this.render();
		},
		
		render: function(){
			var html = this.template(this.model.toJSON());
			this.$el.html(html).appendTo(this.$parent);
			this.setup();
		},
		
		setup: function(){
			this.dimensions = {
				x: this.$el.width(),
github simonsmith / simonsmith.io / assets / scripts / modules / PageUpdater.js View on Github external
renderTemplate: function(tplName, data) {
            var tpl = Handlebars.templates[tplName];
            this.injectTarget.html(tpl(data));

            mediator.publish('content:rendered', data.page_meta);
        }
    });
github ustwo / ustwo.com-frontend / source / index.js View on Github external
function renderPage(pageName, next) {
  pageContent.innerHTML = hb.templates['page-' + pageName](pageData[pageName]);
  next();
}
github adaptlearning / adapt_authoring / frontend / src / modules / contextMenu / views / contextMenuItemView.js View on Github external
render: function() {
      var data = this.model.toJSON();
      var template = Handlebars.templates['contextMenuItem'];
      $(this.el).html(template(data)).appendTo('.context-menu-holder');
      return this;
    },