jtml
Templating engine using JavaScript's tagged template literals.
Installation
$ npm install --save @mjstahl/jtml
Usage
Express
After installing the jtml
package, we set the location of the views and
the engine Express will use to render those views.
app.set('views', './views')
app.set('view engine', 'jtml')
Next create a file named index.jtml
in the ./views
directory with the following
content:
<html>
<head>
<title>${title}</title>
</head>
<body>
<h1>${message}</h1>
</body>
</html>
Now we can configure a route that will render the index.jtml
file.
app.get('/', (req, res) => {
res.render('index', {
title: 'Your first JTML template',
message: 'Looking good!'
})
})