npm install micro-tplmicro-tpl
=========

> Modified from grunt-yomb(MIT) and Used in QQEDU projects.
使用
---
#### 快速入门
将模版字符串输入函数,返回结果字符串:
``javascript
var tpl = require('micro-tpl');
tpl("
<%='hello'%>
");返回:
`javascript
function (it, opt) {
it = it || {};
with(it) {
var _$out_= [];
_$out_.push('', 'hello', '
');
return _$out_.join('');
}
}
`然后可以直接保存成
js文件。#### 可选参数
* strict: 严格模式,不使用with,也就是data只能从it取得。
`javascript
var tpl = require('micro-tpl');tpl("
<%='hello'%>
", { strict: true });
`* path: 如果想使用include,需要将传入的字符串对应的文件地址传入。
`javascript
var tpl = require('micro-tpl');tpl("
<%='hello'%>
", { path: '/home/me/tpl.html' });
`* safe: 进入安全模式,首先会先分析template,如果发现错误就抛错提醒(developing)。
`javascript
var tpl = require('micro-tpl');// it will throw a error
tpl("no<%close", { safe: true, path: '/home/me/bad.html' });
`* ret: 设置引擎编译的结果,默认是
string,可以使用function,则编译后返回函数。* type: 设置模版生成的文件类型,默认是
html, 可以设置成javascript等,则编译后结果会保留换行符。功能介绍
--------
#### 执行脚本
`html
<%
// you javascript code here
console.log('hello world');
%>
`#### 返回字符
`html
<%='hello'%>
`
会返回hello
。#### include模版
`html
<%=include('./tpl.html')(data)%>
``
相关插件
--------
* https://github.com/QQEDU/grunt-imweb-tpl-complie