summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/blocks.js2
-rw-r--r--spec/helpers.js20
-rw-r--r--spec/parser.js4
3 files changed, 25 insertions, 1 deletions
diff --git a/spec/blocks.js b/spec/blocks.js
index d72a44e..8f7c242 100644
--- a/spec/blocks.js
+++ b/spec/blocks.js
@@ -20,7 +20,7 @@ describe('blocks', function() {
equal(result, "0. goodbye! 1. Goodbye! 2. GOODBYE! cruel world!", "The @index variable is used");
});
-
+
it("empty block", function() {
var string = "{{#goodbyes}}{{/goodbyes}}cruel {{world}}!";
var hash = {goodbyes: [{text: "goodbye"}, {text: "Goodbye"}, {text: "GOODBYE"}], world: "world"};
diff --git a/spec/helpers.js b/spec/helpers.js
index 904f56a..ccde982 100644
--- a/spec/helpers.js
+++ b/spec/helpers.js
@@ -9,6 +9,26 @@ describe('helpers', function() {
shouldCompileTo(string, [hash, helpers], "<a href='/root/goodbye'>Goodbye</a>");
});
+ it("helper for raw block gets raw content", function() {
+ var string = "{{{{raw}}}} {{test}} {{{{/raw}}}}";
+ var hash = { test: "hello" };
+ var helpers = { raw: function(options) {
+ return options.fn();
+ } };
+ shouldCompileTo(string, [hash, helpers], " {{test}} ",
+ "raw block helper gets raw content");
+ });
+
+ it("helper for raw block gets parameters", function() {
+ var string = "{{{{raw 1 2 3}}}} {{test}} {{{{/raw}}}}";
+ var hash = { test: "hello" };
+ var helpers = { raw: function(a, b, c, options) {
+ return options.fn() + a + b + c;
+ } };
+ shouldCompileTo(string, [hash, helpers], " {{test}} 123",
+ "raw block helper gets raw content");
+ });
+
it("helper block with complex lookup expression", function() {
var string = "{{#goodbyes}}{{../name}}{{/goodbyes}}";
var hash = {name: "Alan"};
diff --git a/spec/parser.js b/spec/parser.js
index 5b6dc8a..097bb15 100644
--- a/spec/parser.js
+++ b/spec/parser.js
@@ -157,6 +157,10 @@ describe('parser', function() {
shouldThrow(function() {
ast_for("{{#goodbyes}}{{/hellos}}");
}, Error, /goodbyes doesn't match hellos/);
+
+ shouldThrow(function() {
+ ast_for("{{{{goodbyes}}}} {{{{/hellos}}}}");
+ }, Error, /goodbyes doesn't match hellos/);
});
it('knows how to report the correct line number in errors', function() {