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 /lib/handlebars/compiler/printer.js | |
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 'lib/handlebars/compiler/printer.js')
-rw-r--r-- | lib/handlebars/compiler/printer.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/handlebars/compiler/printer.js b/lib/handlebars/compiler/printer.js index 107d4b6..cf7aa48 100644 --- a/lib/handlebars/compiler/printer.js +++ b/lib/handlebars/compiler/printer.js @@ -84,6 +84,22 @@ PrintVisitor.prototype.PartialStatement = function(partial) { } return this.pad('{{> ' + content + ' }}'); }; +PrintVisitor.prototype.PartialBlockStatement = function(partial) { + let content = 'PARTIAL BLOCK:' + partial.name.original; + if (partial.params[0]) { + content += ' ' + this.accept(partial.params[0]); + } + if (partial.hash) { + content += ' ' + this.accept(partial.hash); + } + + content += ' ' + this.pad('PROGRAM:'); + this.padding++; + content += this.accept(partial.program); + this.padding--; + + return this.pad('{{> ' + content + ' }}'); +}; PrintVisitor.prototype.ContentStatement = function(content) { return this.pad("CONTENT[ '" + content.value + "' ]"); |