summaryrefslogtreecommitdiffstats
path: root/spec/qunit_spec.js
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2012-08-21 12:49:40 -0500
committerkpdecker <kpdecker@gmail.com>2012-08-21 12:49:40 -0500
commitdc0426d836027b611b61ebdf0a491e9e6ab889db (patch)
tree8ef9806dbd558719dad3f90a344230bb416a70a2 /spec/qunit_spec.js
parentfc99d90337b6a9e21a498d8b4f52fdc9ad7b156c (diff)
parent6761d4c6d16893f1a347d69956f926f56124e841 (diff)
downloadhandlebars.js-dc0426d836027b611b61ebdf0a491e9e6ab889db.zip
handlebars.js-dc0426d836027b611b61ebdf0a491e9e6ab889db.tar.gz
handlebars.js-dc0426d836027b611b61ebdf0a491e9e6ab889db.tar.bz2
Merge with upstream/master
Diffstat (limited to 'spec/qunit_spec.js')
-rw-r--r--spec/qunit_spec.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/qunit_spec.js b/spec/qunit_spec.js
index f405530..cbbc138 100644
--- a/spec/qunit_spec.js
+++ b/spec/qunit_spec.js
@@ -187,6 +187,20 @@ test("this keyword in paths", function() {
shouldCompileTo(string, hash, "helloHelloHELLO", "This keyword evaluates in more complex paths");
});
+test("this keyword in helpers", function() {
+ var helpers = {foo: function(value, options) {
+ return 'bar ' + value;
+ }};
+ var string = "{{#goodbyes}}{{foo this}}{{/goodbyes}}";
+ var hash = {goodbyes: ["goodbye", "Goodbye", "GOODBYE"]};
+ shouldCompileTo(string, [hash, helpers], "bar goodbyebar Goodbyebar GOODBYE",
+ "This keyword in paths evaluates to current context");
+
+ string = "{{#hellos}}{{foo this/text}}{{/hellos}}";
+ hash = {hellos: [{text: "hello"}, {text: "Hello"}, {text: "HELLO"}]};
+ shouldCompileTo(string, [hash, helpers], "bar hellobar Hellobar HELLO", "This keyword evaluates in more complex paths");
+});
+
suite("inverted sections");
test("inverted sections with unset value", function() {
@@ -1002,6 +1016,19 @@ test("block helpers can take an optional hash", function() {
equals(result, "GOODBYE CRUEL world 12 TIMES", "Hash parameters output");
});
+test("block helpers can take an optional hash with single quoted stings", function() {
+ var template = CompilerContext.compile("{{#goodbye cruel='CRUEL' times=12}}world{{/goodbye}}");
+
+ var helpers = {
+ goodbye: function(options) {
+ return "GOODBYE " + options.hash.cruel + " " + options.fn(this) + " " + options.hash.times + " TIMES";
+ }
+ };
+
+ var result = template({}, {helpers: helpers});
+ equals(result, "GOODBYE CRUEL world 12 TIMES", "Hash parameters output");
+});
+
test("block helpers can take an optional hash with booleans", function() {
var helpers = {
goodbye: function(options) {