Squirrelly with ExpressJS
Since Squirrelly exports the __express
helper, it works out-of-the-box with Express.
Though Squirrelly handles caching, it isn't very sophisticated and the cache only lives for the life of the program (it's stored in a variable). You may want to implement your own caching solution.
index.js
let express = require('express');
let path = require('path');
let app = express();
app.set('view engine', 'squirrelly')
app.get('/', function (req, res) {
res.render('index', {
name: 'Title',
fav: 'Squirrelly'
})
})
let server = app.listen(4000, function () { // This starts the server
console.log("listening to request on port 4000");
});
views/index.squirrelly
<!DOCTYPE html>
<html>
<head>
<title>{{name}}</title>
</head>
<body>
<p>My favorite template engine is {{fav}}</p>
</body>
</html>
Last updated