Node Renderer
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test
.editorconfig
.eslintignore
.eslintrc
.gitignore
.travis.yml
LICENSE
README.md
index.js
package.json

README.md

Renderer

Build Status codecov

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)
  }
})