How to use jsrender - 10 common examples

To help you get started, we’ve selected a few jsrender 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 GEOLYTIX / xyz / routes / login.js View on Github external
// Fail messaged to be displayed for msg query parameter in redirect.
    const msgs = {
      fail: 'Login has failed.<br>'
      + 'This may be due to insufficient priviliges or the account being locked.<br>'
      + 'Please check your inbox for an email with additional details.',
      validation: 'Please check your inbox for an email with additional details.',
      reset: 'The password has been reset for this account.',
      approval: 'This account has been verified but requires administrator approval.',
      badconfig: 'There seems to be a problem with the ACL configuration.'
    };
  
    // Send login view to client.
    res
      .type('text/html')
      .send(jsr
        .templates('./public/views/login.html')
        .render({
          dir: env.path,
          action: req.req.url,
          msg: req.query.msg ? msgs[req.query.msg] : null,
          captcha: env.captcha &amp;&amp; env.captcha[0],
        }));  

  }
github BorisMoore / jsviews.com / test / unit-tests / tests-node.js View on Github external
QUnit.test("jsrender.templates", function(assert) {
	var tmpl = jsrender.templates('./test/templates/name-template.html');
	var html = tmpl({name: "Jo"});
	assert.equal(html, "Name: Jo (name-template.html)", 'jsrender.templates("./file.path.html") compiles template');

	tmpl = jsrender.templates({markup: 'Some {{:~upper("Markup")}} Name: {{:~upper(name)}} {{lower:name}}', helpers: {upper:upper}, converters: {lower:lower}});
	html = tmpl({name: "Jo"});
	assert.equal(html, "Some MARKUP Name: JO jo", 'jsrender.templates({markup: ..., helpers: ..., ...}) compiles template with options');
});
github BorisMoore / jsviews.com / test / unit-tests / tests-node.js View on Github external
QUnit.test("jsrender.templates", function(assert) {
	var tmpl = jsrender.templates('./test/templates/name-template.html');
	var html = tmpl({name: "Jo"});
	assert.equal(html, "Name: Jo (name-template.html)", 'jsrender.templates("./file.path.html") compiles template');

	tmpl = jsrender.templates({markup: 'Some {{:~upper("Markup")}} Name: {{:~upper(name)}} {{lower:name}}', helpers: {upper:upper}, converters: {lower:lower}});
	html = tmpl({name: "Jo"});
	assert.equal(html, "Some MARKUP Name: JO jo", 'jsrender.templates({markup: ..., helpers: ..., ...}) compiles template with options');
});
github BorisMoore / jsviews.com / test / unit-tests / tests-node.js View on Github external
QUnit.test("jsrender.tags.clientTemplate", function(assert) {
	jsrender.views.settings.delimiters("&lt;%", "%&gt;");
	var tmpl = jsrender.compile(
		'\n'
		+ '\n'
		+ '&lt;%clientTemplate "./test/templates/outer.html"/%&gt;\n'
		+ '&lt;%clientTemplate "./test/templates/inner.html"/%&gt;\n'
		+ '\n'
		+ '<div id="result"></div>\n'
		+ '');
	var html = tmpl({name: "Jo"});
	assert.equal(html,
		'\n'
		+ '\n'
		+ '\n'
		+ '\n'
		+ '\n'
		+ '<div id="result"></div>\n'
		+ '',
github BorisMoore / jsviews.com / test / unit-tests / tests-node.js View on Github external
QUnit.test("jsrender.compile", function(assert) {
	var tmpl = jsrender.compile('./test/templates/name-template.html');
	var html = tmpl({name: "Jo"});
	assert.equal(html, "Name: Jo (name-template.html)", 'jsrender.compile("./file.path.html") compiles template');

	tmpl = jsrender.compile('Some {{:~upper("Markup")}} Name: {{:~upper(name)}} {{lower:name}}', {helpers: {upper:upper}, converters: {lower:lower}});
	html = tmpl({name: "Jo"});
	assert.equal(html, "Some MARKUP Name: JO jo", 'jsrender.compile("markup", {helpers: ..., ...}) compiles template with options');
});
github BorisMoore / jsviews.com / test / unit-tests / tests-node.js View on Github external
QUnit.test("jsrender.compile", function(assert) {
	var tmpl = jsrender.compile('./test/templates/name-template.html');
	var html = tmpl({name: "Jo"});
	assert.equal(html, "Name: Jo (name-template.html)", 'jsrender.compile("./file.path.html") compiles template');

	tmpl = jsrender.compile('Some {{:~upper("Markup")}} Name: {{:~upper(name)}} {{lower:name}}', {helpers: {upper:upper}, converters: {lower:lower}});
	html = tmpl({name: "Jo"});
	assert.equal(html, "Some MARKUP Name: JO jo", 'jsrender.compile("markup", {helpers: ..., ...}) compiles template with options');
});
github BorisMoore / jsviews.com / test / unit-tests / tests-node.js View on Github external
QUnit.test("jsrender.renderFile / jsrender.__express", function(assert) {
	var html = jsrender.renderFile('./test/templates/name-template.html', {name: "Jo"});
	assert.equal(html, "Name: Jo (name-template.html)", 'jsrender.renderFile("./file.path.html", data) loads and renders template');

	html = jsrender.__express('./test/templates/name-template.html', {name: "Jo"});
	assert.equal(html, "Name: Jo (name-template.html)", 'jsrender.__express("./file.path.html", data) loads and renders template');
});
github BorisMoore / jsviews.com / test / unit-tests / tests-node.js View on Github external
QUnit.test("jsrender.renderFile / jsrender.__express", function(assert) {
	var html = jsrender.renderFile('./test/templates/name-template.html', {name: "Jo"});
	assert.equal(html, "Name: Jo (name-template.html)", 'jsrender.renderFile("./file.path.html", data) loads and renders template');

	html = jsrender.__express('./test/templates/name-template.html', {name: "Jo"});
	assert.equal(html, "Name: Jo (name-template.html)", 'jsrender.__express("./file.path.html", data) loads and renders template');
});
github BorisMoore / jsviews.com / test / unit-tests / tests-node.js View on Github external
QUnit.test("jsrender.tags.clientTemplate", function(assert) {
	jsrender.views.settings.delimiters("&lt;%", "%&gt;");
	var tmpl = jsrender.compile(
		'\n'
		+ '\n'
		+ '&lt;%clientTemplate "./test/templates/outer.html"/%&gt;\n'
		+ '&lt;%clientTemplate "./test/templates/inner.html"/%&gt;\n'
		+ '\n'
		+ '<div id="result"></div>\n'
		+ '');
	var html = tmpl({name: "Jo"});
	assert.equal(html,
		'\n'
		+ '\n'
		+ '\n'
		+ '\n'
		+ '\n'
		+ '<div id="result"></div>\n'
github OData / model-first / resources / js / editor.js View on Github external
for(var index in errors){
        var error={errorType:null,errDes:'',ln:0};

        error.errDes=!!( errors[index].description)? 
          errors[index].description: errors[index].message;

        if(errors[index].yamlError){
          error.errorType = 'Yaml Error';
          error.ln=errors[index].lineNumber;
        } else {
          error.errorType = 'Simple Yaml Error';
          var range = positionRangeForPath(input, errors[index].path);
          error.ln = range.start.line + 1;
        }
        console.log(error.errDes);
        var t = jsrender.templates('#errorTemp').render(error);
        console.log(t);
        $(t).appendTo('#errors');
      }
    }

jsrender

Best-of-breed templating in browser or on Node.js (with Express 4, Hapi and Browserify integration)

MIT
Latest version published 4 months ago

Package Health Score

70 / 100
Full package analysis