views:

1220

answers:

3

I'm looking for an example using mustache.js with node.js

here is my example but it is not working. Mustache is undefined. I'm using Mustache.js from the master branch.

var sys = require('sys'); var m = require("./mustache");

var view = { title: "Joe", calc: function() { return 2 + 4; } };

var template = "{{title}} spends {{calc}}";

var html = Mustache().to_html(template, view);

sys.puts(html);

A: 

That's not a fake moustache, is it?

+3  A: 

Thanks to Boldr http://boldr.net/create-a-web-app-with-node Had to add the following code to mustache.js

for (var name in Mustache) if (Object.prototype.hasOwnProperty.call(Mustache, name)) exports[name] = Mustache[name];

Not exactly sure what it is doing but it works. Will try to understand it now.

onecoder4u