diff options
Diffstat (limited to 'spec/qunit_spec.js')
-rw-r--r-- | spec/qunit_spec.js | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/spec/qunit_spec.js b/spec/qunit_spec.js index ec58570..5d52e44 100644 --- a/spec/qunit_spec.js +++ b/spec/qunit_spec.js @@ -42,14 +42,6 @@ function shouldCompileToWithPartials(string, hashOrArray, partials, expected, me function compileWithPartials(string, hashOrArray, partials) { var template = CompilerContext[partials ? 'compileWithPartial' : 'compile'](string), ary; if(Object.prototype.toString.call(hashOrArray) === "[object Array]") { - var helpers = hashOrArray[1]; - - if(helpers) { - for(var prop in Handlebars.helpers) { - helpers[prop] = helpers[prop] || Handlebars.helpers[prop]; - } - } - ary = []; ary.push(hashOrArray[0]); ary.push({ helpers: hashOrArray[1], partials: hashOrArray[2] }); @@ -500,6 +492,17 @@ test("the helpers hash is available is nested contexts", function() { "helpers hash is available in nested contexts."); }); +test("the helper hash should augment the global hash", function() { + Handlebars.registerHelper('test_helper', function() { return 'found it!'; }); + + shouldCompileTo( + "{{test_helper}} {{#if cruel}}Goodbye {{cruel}} {{world}}!{{/if}}", [ + {cruel: "cruel"}, + {world: function() { return "world!"; }} + ], + "found it! Goodbye cruel world!!"); +}); + test("Multiple global helper registration", function() { var helpers = Handlebars.helpers; try { @@ -592,6 +595,15 @@ test("Partials with slash and point paths", function() { shouldCompileToWithPartials(string, [hash, {}, {'shared/dude.thing':dude}], true, "Dudes: Jeepers", "Partials can use literal with points in paths"); }); +test("Global Partials", function() { + Handlebars.registerPartial('global_test', '{{another_dude}}'); + + var string = "Dudes: {{> shared/dude}} {{> global_test}}"; + var dude = "{{name}}"; + var hash = {name:"Jeepers", another_dude:"Creepers"}; + shouldCompileToWithPartials(string, [hash, {}, {'shared/dude':dude}], true, "Dudes: Jeepers Creepers", "Partials can use globals or passed"); +}); + test("Multiple partial registration", function() { Handlebars.registerPartial({ 'shared/dude': '{{name}}', |