hbs-express-templ-shiv
v0.1.1
Published
Express 3.x removed layouts to favor templating systems handling them. This is a small shiv function to support layouts with handlebars.
Downloads
4
Maintainers
Readme
Handlebars/Express layout shiv
Express 3.x has removed layouts to favor templating systems handling for their own. This is a small shiv function to make rendering into a generic template easier.
Use
Install on command line
npm install --save hbs-express-templ-shiv
Example Express server
app.js:
var express = require('express')
, handlebars = require('consolidate').handlebars
, render = require('hbs-express-templ-shiv')
app.set('views', __dirname)
app.set('view engine', 'hbs')
app.engine('hbs', handlebars)
// file to take layout from
// defaults to 'layout'
render.layout = 'myLayout'
// name of place to put content in layout
// defaults to 'content' (duh)
render.content = 'myContent'
app.get('/', function (req, res) {
render(res, 'index')
})
app.listen(3000)
myLayout.hbs:
<!DOCTYPE html>
<head>
<title>ya think yer funny?</title>
</head>
<body>
{{> myContent}}
</body>
index.hbs:
<h1>Hello, world!</h1>