summaryrefslogtreecommitdiffstats
path: root/spec/builtins.js
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2013-08-24 12:05:43 -0500
committerkpdecker <kpdecker@gmail.com>2013-08-24 12:05:43 -0500
commit94e5ab8593b878e45833abd50c3242953f6d1901 (patch)
tree3b0a5ec41a9827e6a112df27aeba4ed5002e236a /spec/builtins.js
parent87b5d4ee61605b026506e92c9e8873d867c5f150 (diff)
downloadhandlebars.js-94e5ab8593b878e45833abd50c3242953f6d1901.zip
handlebars.js-94e5ab8593b878e45833abd50c3242953f6d1901.tar.gz
handlebars.js-94e5ab8593b878e45833abd50c3242953f6d1901.tar.bz2
Add additional @data tests
Diffstat (limited to 'spec/builtins.js')
-rw-r--r--spec/builtins.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/builtins.js b/spec/builtins.js
index a29616f..f7aa84d 100644
--- a/spec/builtins.js
+++ b/spec/builtins.js
@@ -84,6 +84,16 @@ describe('builtin helpers', function() {
equal(result, "0. goodbye! 1. Goodbye! 2. GOODBYE! cruel world!", "The @index variable is used");
});
+ it("each with nested @index", function() {
+ var string = "{{#each goodbyes}}{{@index}}. {{text}}! {{#each ../goodbyes}}{{@index}} {{/each}}After {{@index}} {{/each}}{{@index}}cruel {{world}}!";
+ var hash = {goodbyes: [{text: "goodbye"}, {text: "Goodbye"}, {text: "GOODBYE"}], world: "world"};
+
+ var template = CompilerContext.compile(string);
+ var result = template(hash);
+
+ equal(result, "0. goodbye! 0 1 2 After 0 1. Goodbye! 0 1 2 After 1 2. GOODBYE! 0 1 2 After 2 cruel world!", "The @index variable is used");
+ });
+
it("each with function argument", function() {
var string = "{{#each goodbyes}}{{text}}! {{/each}}cruel {{world}}!";
var hash = {goodbyes: function () { return [{text: "goodbye"}, {text: "Goodbye"}, {text: "GOODBYE"}];}, world: "world"};