Templates

Using templates (such as Pug, Handlebars, etc) is easy in Routex, using the Consolidate.js package.

Install

yarn add consolidate
# or
npm install consolidate

Additionally, you will want to install your template engine of choice. For example, Pug:

yarn add pug
# or
npm install pug

Usage

const { TextBody } = require("routex");
const cons = require("consolidate");
app.get("/", () => {
const html = cons.pug("views/index.pug", { name: "Charles" });
return new TextBody(html, "text/html");
});

Don't forgot to use the text/html content type when returning HTML.