kristoferjoseph / addTemplateHelpers

Mixin to add custom temlpate helpers to underscore

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

addTemplateHelpers

Mixin to add custom template helpers to underscore.

Install

npm i addtemplatehelpers

Usage

var _ = require('underscore');
var addTemplateHelpers = require('addTemplateHelpers');
// Mixin the addTemplateHelpers object to augment underscore
_.mixin(addTemplateHelpers);

var data = {
  foo: 'yuppers'
};

_.addTemplateHelpers({
  sum: function(a, b) {
    return a + b;
  }
});

var compiled = _.template('<p><%= data.sum(1,2) %> <%= data.foo %></p>', {
  variable: 'data'
});

compiled(data);
// Will result in <p>3 yuppers</p>

About

Mixin to add custom temlpate helpers to underscore


Languages

Language:JavaScript 100.0%