summaryrefslogtreecommitdiffstats
path: root/spec/basic.js
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2015-02-09 23:54:46 -0600
committerkpdecker <kpdecker@gmail.com>2015-02-09 23:54:46 -0600
commit39121cf8f50ec02b5a979f4911caefef8030161a (patch)
treed73b514d22c9a66dc3d01b232d1bda8176f56d7e /spec/basic.js
parent07f27843dc01058103d084c18a5db297b150d9cb (diff)
downloadhandlebars.js-39121cf8f50ec02b5a979f4911caefef8030161a.zip
handlebars.js-39121cf8f50ec02b5a979f4911caefef8030161a.tar.gz
handlebars.js-39121cf8f50ec02b5a979f4911caefef8030161a.tar.bz2
Handle all potential literal values
Adds support for literal helper names in a few missing cases such as block expressions and subexpressions.
Diffstat (limited to 'spec/basic.js')
-rw-r--r--spec/basic.js35
1 files changed, 23 insertions, 12 deletions
diff --git a/spec/basic.js b/spec/basic.js
index 765e41d..9b6678a 100644
--- a/spec/basic.js
+++ b/spec/basic.js
@@ -230,21 +230,32 @@ describe("basic context", function() {
}, Error);
});
- it("pass string literals", function() {
- shouldCompileTo('{{"foo"}}', {}, "");
- shouldCompileTo('{{"foo"}}', { foo: "bar" }, "bar");
+ it('pass string literals', function() {
+ shouldCompileTo('{{"foo"}}', {}, '');
+ shouldCompileTo('{{"foo"}}', { foo: 'bar' }, 'bar');
+ shouldCompileTo('{{#"foo"}}{{.}}{{/"foo"}}', { foo: ['bar', 'baz'] }, 'barbaz');
});
- it("pass number literals", function() {
- shouldCompileTo("{{12}}", {}, "");
- shouldCompileTo("{{12}}", { "12": "bar" }, "bar");
- shouldCompileTo("{{12.34}}", {}, "");
- shouldCompileTo("{{12.34}}", { "12.34": "bar" }, "bar");
+ it('pass number literals', function() {
+ shouldCompileTo('{{12}}', {}, '');
+ shouldCompileTo('{{12}}', { '12': 'bar' }, 'bar');
+ shouldCompileTo('{{12.34}}', {}, '');
+ shouldCompileTo('{{12.34}}', { '12.34': 'bar' }, 'bar');
+ shouldCompileTo('{{12.34 1}}', { '12.34': function(arg) { return 'bar' + arg; } }, 'bar1');
});
- it("pass boolean literals", function() {
- shouldCompileTo("{{true}}", {}, "");
- shouldCompileTo("{{true}}", { "": "foo" }, "");
- shouldCompileTo("{{false}}", { "false": "foo" }, "foo");
+ it('pass boolean literals', function() {
+ shouldCompileTo('{{true}}', {}, '');
+ shouldCompileTo('{{true}}', { '': 'foo' }, '');
+ shouldCompileTo('{{false}}', { 'false': 'foo' }, 'foo');
+ });
+
+ it('should handle literals in subexpression', function() {
+ var helpers = {
+ foo: function(arg) {
+ return arg;
+ }
+ };
+ shouldCompileTo('{{foo (false)}}', [{ 'false': function() { return 'bar'; } }, helpers], 'bar');
});
});