mito

1.0.5 • Public • Published

mito v1.0.5 Build Status npm version

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

Other small template engines

Dependencies (0)

    Dev Dependencies (3)

    Package Sidebar

    Install

    npm i mito

    Weekly Downloads

    0

    Version

    1.0.5

    License

    MIT

    Last publish

    Collaborators

    • kt3k