bogus.js
v2.0.0
Published
Access Backbone templates from Hogan
Downloads
7
Readme
Bogus.js = Hogan.js + Backbone.js
Bogus.js extends Hogan.js with support for Backbone.js models. This means
that mustache {{tags}}
will look for Backbone.Model attributes, and mustache
{{#sections}}
will iterate over Backbone.Collections.
From the browser
Bogus.js is tied to a specific version of Hogan.js, currently 1.0.5. You will probably want one of the following builds:
- hogan-1.0.5.js: Complete build.
- hogan-1.0.5.min.js: Complete build, minified.
- template-1.0.5.js: Just Hogan.Template.
- template-1.0.5.min.js: Just Hogan.Template, minified.
Make sure Hogan.js and Bogus.js are included in your page in order:
<script src="hogan.js"></script>
<script src="bogus.js"></script>
(Of course, you also want Backbone and dependencies, but Bogus.js won't actually fail without them.)
From Node.js
Install using NPM:
$ npm install bogus.js
Then simply:
var Bogus = require('bogus.js');
Usage
The Bogus
namespace contains all the methods you'd normally find in the
Hogan
namespace. This means you can simply:
var data = new Backbone.Model({
screenName: "ko_si_nus",
});
var template = Bogus.compile("Follow @{{screenName}}.");
var output = template.render(data);
// prints "Follow @ko_si_nus."
console.log(output);