in index.layout
define
{{{block "pageScripts"}}}
in index.hbs
define
{{#contentFor "pageScripts"}}
<script>
// my page specific code here
</script>
{{/contentFor}}
var express = require('express'), | |
exphbs = require('express3-handlebars'), | |
app = express(), | |
hbs; | |
hbs = exphbs.create({ | |
helpers: { | |
block: function (name) { | |
var blocks = this._blocks, | |
content = blocks && blocks[name]; | |
return content ? content.join('\n') : null; | |
}, | |
contentFor: function (name, options) { | |
var blocks = this._blocks || (this._blocks = {}), | |
block = blocks[name] || (blocks[name] = []); | |
block.push(options.fn(this)); | |
} | |
} | |
}); | |
app.engine('handlebars', hbs.engine); | |
app.set('view engine', 'handlebars'); |