diff options
author | kpdecker <kpdecker@gmail.com> | 2015-08-19 08:27:13 -0700 |
---|---|---|
committer | kpdecker <kpdecker@gmail.com> | 2015-08-22 10:59:34 -0700 |
commit | 452afbf2ffdf32a6d7112b727cc95cc6b415e8a5 (patch) | |
tree | c24b4162e48c3de66c36d7160530cab710e77d24 /lib/handlebars/compiler/compiler.js | |
parent | 408192ba9f262bb82be88091ab3ec3c16dc02c6d (diff) | |
download | handlebars.js-452afbf2ffdf32a6d7112b727cc95cc6b415e8a5.zip handlebars.js-452afbf2ffdf32a6d7112b727cc95cc6b415e8a5.tar.gz handlebars.js-452afbf2ffdf32a6d7112b727cc95cc6b415e8a5.tar.bz2 |
Implement block decorators
These allow for a given block to be wrapped in helper methods or metadata and allow for more control over the current container and method before the code is run.
Diffstat (limited to 'lib/handlebars/compiler/compiler.js')
-rw-r--r-- | lib/handlebars/compiler/compiler.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js index a689e7d..64af5da 100644 --- a/lib/handlebars/compiler/compiler.js +++ b/lib/handlebars/compiler/compiler.js @@ -156,6 +156,15 @@ Compiler.prototype = { this.opcode('append'); }, + DecoratorBlock(decorator) { + let program = decorator.program && this.compileProgram(decorator.program); + let params = this.setupFullMustacheParams(decorator, program, undefined), + path = decorator.path; + + this.useDecorators = true; + this.opcode('registerDecorator', params.length, path.original); + }, + PartialStatement: function(partial) { this.usePartial = true; @@ -201,6 +210,10 @@ Compiler.prototype = { this.opcode('append'); } }, + Decorator(decorator) { + this.DecoratorBlock(decorator); + }, + ContentStatement: function(content) { if (content.value) { |