bemRender

express.js view render based on BEM methodology

Download .zip Download .tar.gz View on GitHub

bemRender

express.js view render based on BEM methodology

installation

$ npm install bemrender

how to use

using examples here

configuration

app.set('view engine', 'json');
app.engine('json', require('./lib/bemRender')({
   express : app,
   rootPath : __dirname
}));

render

app.get('/hello', function(req, res){
   res.render("index");
});

directory structure

|_views
| |_index.json
| |_secondPage.json
|_blocks
| |_page
| | |_page.html
| |
| |_button
| |_button.js
| |_button.less
| |_cross.png

code example

blocks/button.html

<button class="{{=it.blockName}} {{=it.mods}}">{{=it.content}}</button>

blocks/button.less

.button {
   border: 1px dotted black;
   background: url("/blocks/button/cross.png") no-repeat;
}

views/index.json

{
   "block" : "page",
   "title" : "Page Title",
   "css" : [],
   "js" : [],
   "content": [
      {
         "block" : "button",
         "content": "Push me",
         "mods" : [
            {"size" : "big"}
         ]
       }
   ]
}