-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use in expressjs? #8
Comments
I can show you my web app as an example. The Probably not the easiest example, but I hope it helps you. |
I mean Express
And
Usage in route action:
|
As the documentation says, those template engines are just a function taking 3 arguments:
Something like this might work with pithy: const p = require('pithy')
const templates = {
// minimal working example
main: (data) => p.html(null, [
p.body(null, [
p.h1(null, data.title),
p.p(null, data.message)
])
])
// …
}
app.engine('unicorn', (template, data, cb) => {
if (!(template in templates))
return cb(new Error('unknwon template'))
return cb(null, templates[template](data))
})
app.set('view engine', 'unicorn') |
How to use in expressjs? I have type "expressjs pithy" in google - no results.
The text was updated successfully, but these errors were encountered: