Masonry

raw JSON →
0.0.2 verified Sat Apr 25 auth: no javascript abandoned

Masonry is a lightweight templating middleware for Express/Connect that wraps EJS templates, last published in 2013 at version 0.0.2. It reads template files into memory from a specified directory and adds a res.render() method. Deprecated by modern view engine integration in Express 3+. No updates since early Node 0.6 era; unmaintained.

error Error: Cannot find module 'underscore'
cause Masonry incorrectly lists underscore as a dependency in older versions but does not require it.
fix
Ensure underscore is installed: npm install underscore, or ignore if not used.
error TypeError: res.render is not a function
cause Masonry middleware not applied or loaded after Express routes.
fix
Apply masonry middleware before route definitions.
deprecated Masonry is abandoned; no updates since 2013. Use Express view engine or consolidates instead.
fix Use app.set('view engine', 'ejs') with Express built-in view engine or switch to consolidate.js.
gotcha Masonry's res.render() overwrites Express's default res.render() method.
fix Be aware that the signature differs: returns via callback or sends directly; incompatible with Express 4+ internal view system.
npm install masonry
yarn add masonry
pnpm add masonry

Sets up Express with Masonry middleware, renders an EJS template.

var express = require('express');
var masonry = require('masonry');
var app = express();
app.use(masonry(__dirname + '/templates'));
app.get('/', function(req, res) {
  res.render('index.ejs', { name: 'World' });
});
app.listen(3000);