summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler/compiler.js
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2015-08-19 08:27:13 -0700
committerkpdecker <kpdecker@gmail.com>2015-08-22 10:59:34 -0700
commit452afbf2ffdf32a6d7112b727cc95cc6b415e8a5 (patch)
treec24b4162e48c3de66c36d7160530cab710e77d24 /lib/handlebars/compiler/compiler.js
parent408192ba9f262bb82be88091ab3ec3c16dc02c6d (diff)
downloadhandlebars.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.js13
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) {