-
Notifications
You must be signed in to change notification settings - Fork 0
Using with Express
Vyacheslav Aristov edited this page Jul 22, 2022
·
3 revisions
app.js
const express = require('express')
const app = express()
app.set('view engine', 'jste')
app.get('/', (req, res) => res.render('app', {
lang : 'en',
title : 'JSTE Express example',
text : 'Hello world!',
}))
views/app.jste
const { html, head, body, meta, title, h1 } = require('jste')
module.exports = (props) => html({
lang : props.lang,
children : [
head([
meta({ charset : 'utf-8' }),
title(props.title),
]),
body([
h1(props.text),
]),
],
})
The JSTE template is a simple CommonJS module.
If you prefer to use the file extension .js
,
you should configure the view engine as follows:
const express = require('express')
const app = express()
app.engine('js', require('jste/engine'))
app.set('view engine', 'js')