nodebars

Handlebars on node.

Usage no npm install needed!

<script type="module">
  import nodebars from 'https://cdn.skypack.dev/nodebars';
</script>

README

nodebars

Handlebars on node.

Install

npm i nodebars --save

Example

{{#extend "./layout"}}
  {{content "body" mode="append"}}
  {{/content}}
{{/entend}}

Following helpers are supported:

  • extend/block/content
  • include

it's same to handlebars-layouts. But you can just give a relative path for a layout file. like ./layout. So that's the difference.

API

normal node application

// the default Bars instance
var nodebars = require('nodebars');

// Bars class
var Bars = nodebars.Bars;

string result = Bars#renderFileSync(file,locals);

Bars class init options

  • enableCache : whether enableCache for file reading
  • extname : the default file extension, default to .html

express

var app = require('express')();
app.engine('.html',require('nodebars').express({
  enableCache: false,
  extname: '.html'
}));

koa

var app = koa()
app.use(bars.koa({
  viewRoot: './views',
  extname: '.html', // default
  enableCache: false // default
}));

License

most code are taken from handlebars-layouts

handlebars-layouts License

MIT © 2015 Shannon Moeller me@shannonmoeller.com

project License

MIT © 2015 Magicdawn http://magicdawn.mit-license.org