Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/imweb/express-micro-tpl
https://github.com/imweb/express-micro-tpl
Last synced: 28 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/imweb/express-micro-tpl
- Owner: imweb
- Created: 2014-10-21T14:57:16.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-11-02T16:36:53.000Z (about 10 years ago)
- Last Synced: 2023-08-09T19:02:48.544Z (over 1 year ago)
- Language: JavaScript
- Size: 137 KB
- Stars: 0
- Watchers: 23
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: Readme.md
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,发生循环引用时会抛出错误。