express-thymeleaf

Integrate ThymeleafJS with Express

Usage no npm install needed!

<script type="module">
  import expressThymeleaf from 'https://cdn.skypack.dev/express-thymeleaf';
</script>

README

Express Thymeleaf

Build Status Coverage Status npm

Integrate ThymeleafJS with Express.

ThymeleafJS returns Promises of processed templates, but Express uses a callback mechanism for receiving rendered/processed HTML. This tiny module saves you having to do the boilerplate of stitching those 2 together to get them to work.

Installation

npm install express-thymeleaf --save

Usage

This module is still under development, denoted by the 0.x semver, in conjunction with the ThymeleafJS project, so expect anything below to change.

import express          from 'express';
import expressThymeleaf from 'express-thymeleaf';
import {TemplateEngine} from 'thymeleaf';

// Configure your application to use Thymeleaf via the express-thymeleaf module
let app = express();
let templateEngine = new TemplateEngine();
app.engine('html', expressThymeleaf(templateEngine));
app.set('view engine', 'html');

// Render views as you would normally in response to requests
app.get('/', function(request, response) {
  response.render('index');
});

app.listen(3000);