bh.js engine (plugin) for express-bem
To use .bh.js
techs to render pages.
$ npm i express-bem-bh --save
var express = require('express');
var expressBem = require('express-bem')(/*params*/); // see the `express-bem` documentation to learn more about params
var app = express();
expressBem.bindTo(app);
expressBem.usePlugin('express-bem-bh', {
force: true, // drops the template requiring cache for every request, it makes reason to use in development environment
source: '_?.bh.js', // the enb-style wildcard to specify a template name (for example, it will render _index.bh.js for the index page)
dataKey: 'data' // name of the field that will contain data into templates, see how to use below
});
app.get('/', function (req, res) {
res.locals.bemjson = {block: 'test'};
// any data to use into templates
// it will be available in templates as `ctx.json().data.message`
res.locals.message = 'Use bh with your Express application';
res.render('pageName');
});
app.listen(3000);
MIT License