0.3.0 • Published 4 years ago

express-thymeleaf v0.3.0

Weekly downloads
73
License
Apache-2.0
Repository
github
Last release
4 years ago

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);