CommonJS compatibility.
This commit is contained in:
+2
-2
@@ -1,4 +1,4 @@
|
||||
require('./handlebars');
|
||||
var handlebars = require('./handlebars');
|
||||
var fs = require('fs');
|
||||
|
||||
if (process.argv.length < 3) {
|
||||
@@ -14,6 +14,6 @@ process.argv.slice(2).forEach(function(val, index, array) {
|
||||
|
||||
var tmpl = fs.readFileSync(parts[1], 'utf8');
|
||||
|
||||
console.log(parts[0] + " = " + Handlebars.compileToString(tmpl).toString());
|
||||
console.log(parts[0] + " = " + handlebars.compileToString(tmpl).toString());
|
||||
});
|
||||
|
||||
|
||||
+8
-3
@@ -1,7 +1,8 @@
|
||||
Handlebars = {
|
||||
var Handlebars = {
|
||||
compile: function(string) {
|
||||
var fnBody = Handlebars.compileFunctionBody(string);
|
||||
return new Function("context", "fallback", fnBody);
|
||||
var fn = new Function("context", "fallback", "Handlebars", fnBody);
|
||||
return function(context, fallback) { return fn(context, fallback, Handlebars); };
|
||||
},
|
||||
|
||||
compileToString: function(string) {
|
||||
@@ -412,4 +413,8 @@ Handlebars.Compiler.prototype = {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// CommonJS Exports
|
||||
exports['compile'] = Handlebars.compile;
|
||||
exports['compileToString'] = Handlebars.compileToString;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
This is the story of guys who work on a project
|
||||
called {{project}}. Their names were {{#people}}{{firstName}} and {{/people}}
|
||||
they both enjoyed working on {{project}}.
|
||||
{{#people}}
|
||||
{{>personPet}}
|
||||
{{/people}}
|
||||
Reference in New Issue
Block a user