@hoajs/mustache
v0.1.1
Published
A Mustache-based view renderer for Hoa.
Downloads
136
Readme
@hoajs/mustache
A Mustache-based view renderer for Hoa.
Installation
$ npm i @hoajs/mustache --saveQuick Start
import { Hoa } from 'hoa'
import { mustache} from '@hoajs/mustache'
const app = new Hoa()
app.extend(mustache())
const userTemplate = '<p>Hello, my name is {{name}}. I have {{kids.length}} kids:</p><ul>{{#kids}}{{> kid}}{{/kids}}</ul>'
const kidTemplate = '<li>{{name}} is {{age}}</li>'
app.use(async (ctx) => {
const html = ctx.render(
userTemplate,
{
name: 'David',
kids: [
{ name: 'Jack', age: 18 },
{ name: 'John', age: 20 }
]
},
{
kid: kidTemplate
}
)
ctx.res.body = html
})
export default appDocumentation
The documentation is available on hoa-js.com
Test (100% coverage)
$ npm testLicense
MIT
