beardcomb

Hogan.js adapter for Express.js applications, with support for file-based partials and foundation template.

#Beardcomb v0.4.1#

Hogan.js adapter for Express.js applications, with support for file-based partials and foundation template.

##Installation##

For Express 4.x users:

  • For Express 3.x : npm install beardcomb@0.3.1
  • For Express 2.x : npm install beardcomb@0.2.3

##How to use##

###Express 4.x###

var express = require('express'),
    router = new express.Router(),
    beardcomb = require('beardcomb'),
    app = express();
 
// beardcomb config 
app.engine('html', beardcomb);
app.set('view engine', 'html')
app.set('views', __dirname + '/views');
 
// example route 
router.get('/', function(reqres) {
    res.render('index', {
        locals: {
            title: 'beardcomb',
            type: 'hogan template'
        },
        partials: {
            info: '<p>I am an awesome <b>{{type}}</b></p>' //string based partials 
        },
        foundation: 'layout' //support fo foundation template 
    });
});
 
app.use(router);
 
// start server 
app.listen(3000);

See here for usage instructions with Express 3.x and Express 2.x

##Features##

  • NEW IN 0.4.x Support for Express 4.x and Hogan.js 3.x
  • Foundation template: create a file called 'layout.html' and add the tag {{{contents}}}, it will parse the view contents into it
  • Partials can be passed either as html code as seen above, or as a template file
  • Support for recursive lookup of partials template files
  • Support for custom foundation template name (via options.foundation)
  • Legacy support for Express 3.x (beardcomb@0.3.1) & 2.x (beardcomb@0.2.3)

##Demo##

npm install
node demo/app.js

##Test##

npm test

##Contributors##

##License##

The MIT License (MIT) Copyright (c) 2012, 2015 Stephane P. Pericat

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.