summaryrefslogtreecommitdiffstats
path: root/spec/track-ids.js
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2015-08-03 12:16:02 -0500
committerkpdecker <kpdecker@gmail.com>2015-08-03 12:16:02 -0500
commit1c08771215af7377fb8f33a26f64b3af0e06c168 (patch)
tree37bc4ee51c4b6d42f5bc67f3863d27a11e4edfa3 /spec/track-ids.js
parent9f265b97614e5c4763dc3d2d7343fc2472a6cc1a (diff)
downloadhandlebars.js-1c08771215af7377fb8f33a26f64b3af0e06c168.zip
handlebars.js-1c08771215af7377fb8f33a26f64b3af0e06c168.tar.gz
handlebars.js-1c08771215af7377fb8f33a26f64b3af0e06c168.tar.bz2
Fix track id handling in partials
Fixes #914
Diffstat (limited to 'spec/track-ids.js')
-rw-r--r--spec/track-ids.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/track-ids.js b/spec/track-ids.js
index 88db789..30a4661 100644
--- a/spec/track-ids.js
+++ b/spec/track-ids.js
@@ -190,4 +190,48 @@ describe('track ids', function() {
});
});
});
+
+ describe('partials', function() {
+ var helpers = {
+ blockParams: function(name, options) {
+ return name + ':' + options.ids[0] + '\n';
+ },
+ wycats: function(name, options) {
+ return name + ':' + options.data.contextPath + '\n';
+ }
+ };
+
+ it('should pass track id for basic partial', function() {
+ var template = CompilerContext.compile('Dudes: {{#dudes}}{{> dude}}{{/dudes}}', {trackIds: true}),
+ hash = {dudes: [{name: 'Yehuda', url: 'http://yehuda'}, {name: 'Alan', url: 'http://alan'}]};
+
+ var partials = {
+ dude: CompilerContext.compile('{{wycats name}}', {trackIds: true})
+ };
+
+ equals(template(hash, {helpers: helpers, partials: partials}), 'Dudes: Yehuda:dudes.0\nAlan:dudes.1\n');
+ });
+
+ it('should pass track id for context partial', function() {
+ var template = CompilerContext.compile('Dudes: {{> dude dudes}}', {trackIds: true}),
+ hash = {dudes: [{name: 'Yehuda', url: 'http://yehuda'}, {name: 'Alan', url: 'http://alan'}]};
+
+ var partials = {
+ dude: CompilerContext.compile('{{#each this}}{{wycats name}}{{/each}}', {trackIds: true})
+ };
+
+ equals(template(hash, {helpers: helpers, partials: partials}), 'Dudes: Yehuda:dudes..0\nAlan:dudes..1\n');
+ });
+
+ it('should invalidate context for partials with parameters', function() {
+ var template = CompilerContext.compile('Dudes: {{#dudes}}{{> dude . bar="foo"}}{{/dudes}}', {trackIds: true}),
+ hash = {dudes: [{name: 'Yehuda', url: 'http://yehuda'}, {name: 'Alan', url: 'http://alan'}]};
+
+ var partials = {
+ dude: CompilerContext.compile('{{wycats name}}', {trackIds: true})
+ };
+
+ equals(template(hash, {helpers: helpers, partials: partials}), 'Dudes: Yehuda:true\nAlan:true\n');
+ });
+ });
});