micro-templating function
This is forked from John Resig's micro-templating.
Just 222B minified.
Similar to .ejs
<html>
<head>
<title><%= title %></title>
</head>
<body>
<ul>
<% items.forEach(function (item) { %>
<li><a href="<%= item.url %>"><%= item.name %></a></li>
<% }) %>
</ul>
</body>
</html>
With the above string, the following renders it.
mito(above)({title: 'Hello', items: [
{name: 'Linux', url: 'https://github.com/torvalds/linux'},
{name: 'XNU', url: 'https://github.com/opensource-apple/xnu'},
{name: 'Hurd', url: 'https://www.gnu.org/software/hurd/hurd.html'}
]})
npm install mito
var mito = require('mito')
- @param {String} str The template string
Returns template function compiled with the given template string.
- @param {Object} obj The template parameter
Returns the rendered string with template parameter
- 222B minified
- No dependency
- No cache mechanism
- No include/import/require support
- Line breaks become whitespace (0x20)
MIT