mito
v1.0.5
Published
micro-templating function
Downloads
8
Readme
mito v1.0.5
micro-templating function
This is forked from John Resig's micro-templating.
Just 222B minified.
Syntax
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'}
]})
Install
npm install mito
API
var mito = require('mito')
mito(str)
- @param {String} str The template string
Returns template function compiled with the given template string.
mito(str)(obj)
- @param {Object} obj The template parameter
Returns the rendered string with template parameter
Feature / Restriction
- 222B minified
- No dependency
- No cache mechanism
- No include/import/require support
- Line breaks become whitespace (0x20)
License
MIT