Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/imweb/express-micro-tpl


https://github.com/imweb/express-micro-tpl

Last synced: 28 days ago
JSON representation

Awesome Lists containing this project

README

        

express-micro-tpl
=================

> `micro-tpl`的express插件,可使express支持micro-tpl模版。

使用
----

```javascript
var express = require('express')
, tpl = require('express-micro-tpl');

express()
.set('views', __dirname + '/views')
.set('view engine', 'html')
.engine('html', tpl.__express)
.get('/', function (req, res) {
// render views/index.html
res.render('index', { user: req.user });
});
```

基本功能
--------

#### 执行脚本

```html
<%
// you javascript code here
console.log('hello world');
%>
```

#### 返回字符

```html

<%='hello'%>


```
会返回`

hello

`。

#### 转义字符

```html

<%=='

hello

'%>
```

#### include模版

```html
<%=include('./tpl.html')(data)%>
```
会include相对于本模版的tpl.html文件,可以多重include,发生循环引用时会抛出错误。