Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kt3k/mito
Tiny (222B) micro-templating engine
https://github.com/kt3k/mito
template-engine
Last synced: 20 days ago
JSON representation
Tiny (222B) micro-templating engine
- Host: GitHub
- URL: https://github.com/kt3k/mito
- Owner: kt3k
- License: mit
- Created: 2015-12-28T14:12:54.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-10-26T06:33:12.000Z (about 8 years ago)
- Last Synced: 2024-10-10T17:14:56.947Z (about 1 month ago)
- Topics: template-engine
- Language: JavaScript
- Homepage:
- Size: 18.6 KB
- Stars: 10
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mito v1.0.5 [![Build Status](https://travis-ci.org/kt3k/mito.svg)](https://travis-ci.org/kt3k/mito) [![npm version](https://img.shields.io/npm/v/mito.svg)](https://www.npmjs.com/package/mito)
> micro-templating function
This is forked from John Resig's [micro-templating](http://ejohn.org/blog/javascript-micro-templating/).
Just [222B minified](https://raw.githubusercontent.com/kt3k/mito/master/mito.min.js).
# Syntax
Similar to `.ejs`
```ejs
<%= title %>
- <%= item.name %>
<% items.forEach(function (item) { %>
<% }) %>
```
With the above string, the following renders it.
```js
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
```js
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
- [doT](https://github.com/olado/doT)
- [lodash.template](https://www.npmjs.com/package/lodash.template)
- [underscore#template](http://underscorejs.org/#template)