diff options
author | kpdecker <kpdecker@gmail.com> | 2015-08-14 15:18:52 -0500 |
---|---|---|
committer | kpdecker <kpdecker@gmail.com> | 2015-08-22 10:59:08 -0700 |
commit | 91ffd32cad32b2d1cd310ff94f65b28c428206ac (patch) | |
tree | 13cb346dfb0e6dc72dc6dddbcdf3ed8e61ebaeff /src | |
parent | 2571dd8e8e43fd320672763564b16a5b3ae33966 (diff) | |
download | handlebars.js-91ffd32cad32b2d1cd310ff94f65b28c428206ac.zip handlebars.js-91ffd32cad32b2d1cd310ff94f65b28c428206ac.tar.gz handlebars.js-91ffd32cad32b2d1cd310ff94f65b28c428206ac.tar.bz2 |
Implement partial blocks
This allows for failover for missing partials as well as limited templating ability through the `{{> @partial-block }}` partial special case.
Partial fix for #1018
Diffstat (limited to 'src')
-rw-r--r-- | src/handlebars.l | 1 | ||||
-rw-r--r-- | src/handlebars.yy | 7 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/handlebars.l b/src/handlebars.l index f7df8f5..39a7884 100644 --- a/src/handlebars.l +++ b/src/handlebars.l @@ -80,6 +80,7 @@ ID [^\s!"#%-,\.\/;->@\[-\^`\{-~]+/{LOOKAHEAD} return 'CLOSE_RAW_BLOCK'; } <mu>"{{"{LEFT_STRIP}?">" return 'OPEN_PARTIAL'; +<mu>"{{"{LEFT_STRIP}?"#>" return 'OPEN_PARTIAL_BLOCK'; <mu>"{{"{LEFT_STRIP}?"#" return 'OPEN_BLOCK'; <mu>"{{"{LEFT_STRIP}?"/" return 'OPEN_ENDBLOCK'; <mu>"{{"{LEFT_STRIP}?"^"\s*{RIGHT_STRIP}?"}}" this.popState(); return 'INVERSE'; diff --git a/src/handlebars.yy b/src/handlebars.yy index a05b477..ee0eddb 100644 --- a/src/handlebars.yy +++ b/src/handlebars.yy @@ -17,6 +17,7 @@ statement | block -> $1 | rawBlock -> $1 | partial -> $1 + | partialBlock -> $1 | content -> $1 | COMMENT { $$ = { @@ -101,6 +102,12 @@ partial }; } ; +partialBlock + : openPartialBlock program closeBlock -> yy.preparePartialBlock($1, $2, $3, @$) + ; +openPartialBlock + : OPEN_PARTIAL_BLOCK partialName param* hash? CLOSE -> { name: $2, params: $3, hash: $4, strip: yy.stripFlags($1, $5) } + ; param : helperName -> $1 |