hbs-express-templ-shiv

0.1.1 • Public • Published

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>

Package Sidebar

Install

npm i hbs-express-templ-shiv

Weekly Downloads

2

Version

0.1.1

License

MIT

Last publish

Collaborators

  • mkgh