summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Ezell <jesse.ezell@neudesic.com>2013-07-11 12:28:37 -0700
committerkpdecker <kpdecker@gmail.com>2014-02-09 14:41:32 -0600
commit954253305a0deadf25236e087dd4d2908aee715a (patch)
tree54891e2d5437d0a14120eba38e7000139aa530d7
parent7a7ad74ff1c4fe8685d33cceebe03f1474eb865d (diff)
downloadhandlebars.js-954253305a0deadf25236e087dd4d2908aee715a.zip
handlebars.js-954253305a0deadf25236e087dd4d2908aee715a.tar.gz
handlebars.js-954253305a0deadf25236e087dd4d2908aee715a.tar.bz2
Add {{{{ }}}} for raw blocks
-rw-r--r--spec/blocks.js8
-rw-r--r--src/handlebars.l5
-rw-r--r--src/handlebars.yy3
3 files changed, 15 insertions, 1 deletions
diff --git a/spec/blocks.js b/spec/blocks.js
index d72a44e..b9672af 100644
--- a/spec/blocks.js
+++ b/spec/blocks.js
@@ -21,6 +21,14 @@ describe('blocks', function() {
equal(result, "0. goodbye! 1. Goodbye! 2. GOODBYE! cruel world!", "The @index variable is used");
});
+
+ it("raw block", function() {
+ var string = "{{{{ {{test}} }}}}";
+ var hash = { test: "hello" };
+ shouldCompileTo(string, hash, " {{test}} ",
+ "raw block ignores blocks");
+ });
+
it("empty block", function() {
var string = "{{#goodbyes}}{{/goodbyes}}cruel {{world}}!";
var hash = {goodbyes: [{text: "goodbye"}, {text: "Goodbye"}, {text: "GOODBYE"}], world: "world"};
diff --git a/src/handlebars.l b/src/handlebars.l
index 630840e..51e921a 100644
--- a/src/handlebars.l
+++ b/src/handlebars.l
@@ -54,6 +54,11 @@ ID [^\s!"#%-,\.\/;->@\[-\^`\{-~]+/{LOOKAHEAD}
<mu>"(" return 'OPEN_SEXPR';
<mu>")" return 'CLOSE_SEXPR';
+<mu>"{{{{"[^\x00]*"}}}}" {
+ yytext = yytext.substr(4, yyleng-8);
+ this.popState();
+ return 'RAW_BLOCK';
+ }
<mu>"{{"{LEFT_STRIP}?">" return 'OPEN_PARTIAL';
<mu>"{{"{LEFT_STRIP}?"#" return 'OPEN_BLOCK';
<mu>"{{"{LEFT_STRIP}?"/" return 'OPEN_ENDBLOCK';
diff --git a/src/handlebars.yy b/src/handlebars.yy
index 40f68ce..8b5b774 100644
--- a/src/handlebars.yy
+++ b/src/handlebars.yy
@@ -35,7 +35,8 @@ statements
;
statement
- : openInverse program closeBlock -> new yy.BlockNode($1, $2.inverse, $2, $3, @$)
+ : RAW_BLOCK { $$ = new yy.ContentNode($1, @$); }
+ | openInverse program closeBlock -> new yy.BlockNode($1, $2.inverse, $2, $3, @$)
| openBlock program closeBlock -> new yy.BlockNode($1, $2, $2.inverse, $3, @$)
| mustache -> $1
| partial -> $1