node-xtemplate
v0.1.6
Published
A node.js wrapper around xtemplate engine
Downloads
23
Readme
Node xTemplate
A node.js wrapper around xtemplate engine
Install
$ npm install --save node-xtemplate
Usage
demo.xtpl
<p>{{ message }}</p>
demo.js
const xTemplate = require('node-xtemplate')
// callback
xTemplate.render(path.resolve(__dirname, 'demo.xtpl'), {
message: 'hello world'
}, function (err, result) {
// result => <p>hello world</p>
})
// or promise
xTemplate
.render(path.resolve(__dirname, 'demo.xtpl'), { message: 'hello world' })
.then(function (result) {
// result => <p>hello world</p>
})
.catch(function (err) {
// if err
})
API
render(path, data[, options], callback)
path
Type: string
The path of template file.
data
Type: object
The template data.
options
extname
Type: string
strict
Type: boolean
catchError
Type: boolean
cache
Type: boolean
encoding
Type: string
Default: utf-8
callback(err, result)
Type: function
Done callback