0.1.6 • Published 7 years ago

node-xtemplate v0.1.6

Weekly downloads
6
License
MIT
Repository
github
Last release
7 years ago

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 © 汪磊