visionmedia/consolidate.js — pull request #119 by sebowles51 (2013-07-21 10:28:28+00:00)
Title: Allow defs to be passed through to dot compile.

Pass down custom defines to templates, which doT.js allows but using with Consolidate.JS currently does not. Small change.

Example:

| - test.js
| - views/home.html
| - views/main.html

```html

it.h at top of main.html = {{=it.h}}

{{#def.loadfile('./home.html')}}

it.h from within home.html = {{=it.h}}

```

```js

var fs = require('fs');
var dot = require('consolidate').dot;
var express = require('express');
var server = express();
var VIEWS = __dirname + '/views/';

server.set('views', VIEWS);
server.set('view engine', 'html' );
server.engine('html', dot );

server.get('/', function root(req,res) {

var _def = {
loadfile: function(path) {
return fs.readFileSync(VIEWS + path);
}
};

var options = {
h: 'hi',
_def: _def
}

res.render('main', options);
});
server.listen(8000);

```

localhost:3000/ returns:

```html

it.h at top of main.html = hi

it.h from within home.html = hi

```