AcyOrt use renderer for rendering
Built-in supports yaml
,swig
,markdown
renders
yaml
use js-yamlswig
use swig-templatesmarkdown
use @acyort/markdownconst { 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 })
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)
}
})