summaryrefslogtreecommitdiffstats
path: root/spec/qunit_spec.js
diff options
context:
space:
mode:
authorLes Hill <leshill@gmail.com>2013-02-25 23:03:16 -0800
committerLes Hill <leshill@gmail.com>2013-03-19 21:41:36 -0700
commit53de75927ce3ff622901ae00b39c5e677fb6ba25 (patch)
treec18c6a7a5203313879822a18779e65edf6dc7b5e /spec/qunit_spec.js
parentbcc15ea5e78a3368344204c805e4666681e7253e (diff)
downloadhandlebars.js-53de75927ce3ff622901ae00b39c5e677fb6ba25.zip
handlebars.js-53de75927ce3ff622901ae00b39c5e677fb6ba25.tar.gz
handlebars.js-53de75927ce3ff622901ae00b39c5e677fb6ba25.tar.bz2
Add contexts for string mode hash values
Allows for evaluating hash parameters such as ../city in string mode.
Diffstat (limited to 'spec/qunit_spec.js')
-rw-r--r--spec/qunit_spec.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/qunit_spec.js b/spec/qunit_spec.js
index f12e44c..356c63c 100644
--- a/spec/qunit_spec.js
+++ b/spec/qunit_spec.js
@@ -1286,6 +1286,32 @@ test("in string mode, hash parameters get type information", function() {
equal(result, "Helper called");
});
+test("in string mode, hash parameters get context information", function() {
+ var template = CompilerContext.compile('{{#with dale}}{{tomdale he.says desire="need" noun=../dad/joke bool=true}}{{/with}}', { stringParams: true });
+
+ var context = {dale: {}};
+
+ var helpers = {
+ tomdale: function(exclamation, options) {
+ equal(exclamation, "he.says");
+ equal(options.types[0], "ID");
+
+ equal(options.contexts.length, 1);
+ equal(options.hashContexts.noun, context);
+ equal(options.hash.desire, "need");
+ equal(options.hash.noun, "dad.joke");
+ equal(options.hash.bool, true);
+ return "Helper called";
+ },
+ "with": function(context, options) {
+ return options.fn(options.contexts[0][context]);
+ }
+ };
+
+ var result = template(context, { helpers: helpers });
+ equal(result, "Helper called");
+});
+
test("when inside a block in String mode, .. passes the appropriate context in the options hash to a block helper", function() {
var template = CompilerContext.compile('{{#with dale}}{{#tomdale ../need dad.joke}}wot{{/tomdale}}{{/with}}', {stringParams: true});