AcyOrt use renderer for rendering

Defaults

Built-in supports yamlswigmarkdown renders

const { renderer } = acyort

// default swig, yaml and markdown
renderer.render('swig', { title: 'swig' })
renderer.renderFile('swig', 'path/to/html', { title: 'swig' })

renderer.render('yaml', 'title: yaml')
renderer.renderFile('yaml', 'path/to/yaml')

renderer.render('markdown', '# h1')
renderer.renderFile('markdown', 'path/to/markdown')

// markdown supports code highlighting and math latex, and can set if show line numbers
renderer.renderFile('markdown', 'path/to/markdown', { lineNumbers: true })

Customs

Register render engine

// register ejs
const ejs = require('ejs')

renderer.register('ejs', {
  render: ejs.render,
  renderFile: (file, data) => {
    const text = fs.readFileSync(file).toString()
    return ejs.render(text, data)
  }
})

Contents