@acyort/renderer 中文文档教程
Renderer
节点渲染器
Install
$ npm i @acyort/renderer -S
Usage
const Renderer = require('@acyort/renderer')
const renderer = new Renderer()
// default engine swig, yaml and markdown
renderer.render('swig', { title: 'swig' })
renderer.renderFile('swig', 'html path', { title: 'swig' })
renderer.render('yaml', 'title: yaml')
renderer.renderFile('yaml', 'yml path')
renderer.render('markdown', '# h1')
renderer.renderFile('markdown', 'markdown path')
// engine register
renderer.register('ejs', {
render: ejs.render,
renderFile: (file, data) => {
const text = fs.readFileSync(file).toString()
return ejs.render(text, data)
}
})
Renderer
Node Renderer
Install
$ npm i @acyort/renderer -S
Usage
const Renderer = require('@acyort/renderer')
const renderer = new Renderer()
// default engine swig, yaml and markdown
renderer.render('swig', { title: 'swig' })
renderer.renderFile('swig', 'html path', { title: 'swig' })
renderer.render('yaml', 'title: yaml')
renderer.renderFile('yaml', 'yml path')
renderer.render('markdown', '# h1')
renderer.renderFile('markdown', 'markdown path')
// engine register
renderer.register('ejs', {
render: ejs.render,
renderFile: (file, data) => {
const text = fs.readFileSync(file).toString()
return ejs.render(text, data)
}
})
更多