UNPKG

1.91 kBMarkdownView Raw
1# Node xTemplate
2
3[![NPM version][npm-image]][npm-url]
4[![NPM download][download-image]][download-url]
5[![Build Status][travis-image]][travis-url]
6[![Dependency Status][dependency-image]][dependency-url]
7[![devDependency Status][devdependency-image]][devdependency-url]
8[![Code Style][style-image]][style-url]
9
10[npm-image]: https://badge.fury.io/js/node-xtemplate.svg
11[npm-url]: https://npmjs.org/package/node-xtemplate
12[download-image]: https://img.shields.io/npm/dm/node-xtemplate.svg
13[download-url]: https://npmjs.org/package/node-xtemplate
14[travis-image]: https://travis-ci.org/zce/node-xtemplate.svg?branch=master
15[travis-url]: https://travis-ci.org/zce/node-xtemplate
16[dependency-image]: https://david-dm.org/zce/node-xtemplate/status.svg
17[dependency-url]: https://david-dm.org/zce/node-xtemplate
18[devdependency-image]: https://david-dm.org/zce/node-xtemplate/dev-status.svg
19[devdependency-url]: https://david-dm.org/zce/node-xtemplate?type=dev
20[style-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
21[style-url]: http://standardjs.com/
22
23> A node.js wrapper around xtemplate engine
24
25
26## Install
27
28```sh
29$ npm install --save node-xtemplate
30```
31
32
33## Usage
34
35demo.xtpl
36```html
37<p>{{ message }}</p>
38```
39
40demo.js
41
42```js
43const xTemplate = require('node-xtemplate');
44
45xTemplate.render(path.resolve(__dirname, 'demo.xtpl'), {
46 message: 'hello world'
47}, function (err, result) {
48 // => <p>hello world</p>
49})
50```
51
52
53## API
54
55### render(path, data[, options], callback)
56
57#### path
58
59Type: `string`
60
61The path of template file.
62
63#### data
64
65Type: `object`
66
67The template data.
68
69#### options
70
71##### extname
72
73Type: `string`
74
75##### strict
76
77Type: `boolean`
78
79##### catchError
80
81Type: `boolean`
82
83##### cache
84
85Type: `boolean`
86
87##### encoding
88
89Type: `string`<br>
90Default: `utf-8`
91
92#### callback(err, result)
93
94Type: `function`
95
96Done callback
97
98
99## License
100
101[MIT](LICENSE) © [汪磊](http://github.com/zce)
102