
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
a template engine, using Lodash's template syntax and supporting including other templates
Tarim is a template engine, using Lodash's template syntax and supporting include other templates.
const tmplEngine = require('tarim');
let str;
let tmpl;
// string
str = 'hello <%= user %>!';
tmpl = tmplEngine(str);
tmpl({ 'user': 'fred' })
// 'hello fred!'
// escaped string
str = '<b><%- value %></b>';
tmpl = tmplEngine(str);
tmpl({ 'value': '<script>' })
// '<b><script></b>'
// array
str = `
<% users.forEach(u => { %>
<li><%- u %></li>
<% }) %>
`;
tmpl = tmplEngine(str);
tmpl({ 'users': ['fred', 'barney'] })
// '<li>fred</li><li>barney</li>'
// ES6 template string
str = 'hello ${ user }!';
tmpl = tmplEngine(str);
tmpl({ 'user': 'pebbles' })
// 'hello pebbles!'
// escaping delimiters
str = '<%= "\\<%- value %\\>" %>';
tmpl = tmplEngine(str);
tmpl({ 'value': 'ignored' })
// => '<%- value %>'
const tmplEngine = require('tarim');
let str;
let tmpl;
// print() function
str = '<% users.forEach(u => print("<li>" + u + "</li>")) %>';
tmpl = tmplEngine(str);
tmpl({ 'users': ['fred', 'barney'] })
// '<li>fred</li><li>barney</li>'
// template function's source
str = 'hello world';
tmpl = tmplEngine(str);
tmpl.source
// 'function(obj) {\nobj || (obj = {});\nvar __t, __p = \'\';\nwith (obj) {\n__p += \'hello world\';\n\n}\nreturn __p\n}'
A template could be included into another template.
<% include templateFileName %>
The above line will be replaced by the content of file templateFileName.template.
The default path of included template files is the current working directory process.cwd(), and the default extension of template files is .template. You could customize them by setting Option.includePath and Option.includeExt.
Option.includePath is to specify the location of a directory of template files relative to process.cwd() directory. It could also be an absolute path.
const tmplEngine = require('tarim');
const str = '<% include data %>';
const tmpl = tmplEngine(str, {
includePath: './templates',
includeExt: '.template',
});
const tmplEngine = require('tarim');
let str;
let option;
let tmpl;
// data object
str = 'hello <%= data.user %>!';
option = { 'variable': 'data' };
tmpl = tmplEngine(str, option);
tmpl({ user: 'world'})
// 'hello world!'
// sourceURL option
str = 'hello <%= user %>!';
option = {
'sourceURL': '/basic/greeting.jst'
};
tmpl = tmplEngine(str, option);
// => source file "greeting.jst" will be
// => under the Sources tab or Resources panel of the web inspector.
// custom template delimiters
option = {
'interpolate': /{{([\s\S]+?)}}/g
}
str = 'hello {{ user }}!';
tmpl = tmplEngine({ 'user': 'mustache' });
// 'hello mustache!'
tmplEngine([string=''], [options={}])
Arguments
Returns
(Function): Returns the compiled template function.
MIT
FAQs
a template engine, using Lodash's template syntax and supporting including other templates
We found that tarim demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.