twitter / hogan.js

A compiler for the Mustache templating language
http://twitter.github.io/hogan.js
Apache License 2.0
5.14k stars 431 forks source link

Hulk, Hogan and Browserify #216

Closed tscok closed 3 years ago

tscok commented 9 years ago

I have some simple templates, this is an example:

// assets/dom/users.mustache

<div id="users"><p>Here are the {{ users }}</p></div>

Next I pre-compiled the templates using the command line utility Hulk:

hulk assets/dom/* > assets/js/hulks.js

Which gives me a js file with all the compiled templates:

// assets/js/hulks.js

if (!!!templates) var templates = {};
templates["users"] = new Hogan.Template({code: function (c,p,i)...

In my app.js file I do:

// assets/js/app.js

var templates = require('./hulks.js');

Now, the browser gives me a Uncaught ReferenceError: Hogan is not defined error pointing to the new Hogan.Template({... part of the templates file. So obviously I need to require hogan.js too:

// assets/js/app.js

var hogan = require('hogan.js');
var templates = require('./hulks.js');

The problem is that the error remains. What am I doing wrong?

Irrelon commented 9 years ago

Haven't tested but looking at your code shouldn't you be requiring hogan.js and assigning to Hogan (capital H)?