node-xtemplate

0.1.6 • Public • Published

Node xTemplate

NPM version NPM download Build Status Dependency Status devDependency Status Code Style

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

License

MIT © 汪磊

Package Sidebar

Install

npm i node-xtemplate

Weekly Downloads

7

Version

0.1.6

License

MIT

Last publish

Collaborators

  • zce
  • zceme