express-views-dom-layouts

Layouts support for express-views-dom.

express-views-dom-layouts

Layouts support for express-views-dom, the DOM view engine for Express.

Lets you define and override blocks by extending other views as layouts.

via npm:

$ npm install --save express-views-dom-layouts

First setup express-views-dom - see its README.

Then use as in the following example:

"views/home.html":

<extends from="layout-default">
  <block for="title">Home Page</block>
  <block for="content">
    Welcome home!
  </block>
</extends>

"views/layout-default.html":

<!doctype html>
<html>
  <head>
    <title><block name="title">Default Title</block></title>
  </head>
  <body>
    <block name="content">
      Default content.
    </block>
  </body>
</html>

JavaScript:

// assumes already setup express-views-dom 
 
var domLayouts = require('express-views-dom-layouts');
 
app.get('/', function (reqres) {
  res.render('home', {
    renderfunction (windowdoneparams) {
      domLayouts(window, done, params, function () {
        // we now have the fully stitched HTML 
        // and could do more DOM work if desired 
 
        done();
      });
    }
  });
});

Results in:

<!doctype html>
<html>
  <head>
    <title>Home Page</title>
  </head>
  <body>
    Welcome home!
  </body>
</html>