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 /spec/parser.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 'spec/parser.js')
-rw-r--r-- | spec/parser.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/parser.js b/spec/parser.js index 82c32d0..5b60f93 100644 --- a/spec/parser.js +++ b/spec/parser.js @@ -113,6 +113,18 @@ describe('parser', function() { equals(astFor('{{> shared/partial?.bar}}'), '{{> PARTIAL:shared/partial?.bar }}\n'); }); + it('parsers partial blocks', function() { + equals(astFor('{{#> foo}}bar{{/foo}}'), '{{> PARTIAL BLOCK:foo PROGRAM:\n CONTENT[ \'bar\' ]\n }}\n'); + }); + it('should handle parser block mismatch', function() { + shouldThrow(function() { + astFor('{{#> goodbyes}}{{/hellos}}'); + }, Error, (/goodbyes doesn't match hellos/)); + }); + it('parsers partial blocks with arguments', function() { + equals(astFor('{{#> foo context hash=value}}bar{{/foo}}'), '{{> PARTIAL BLOCK:foo PATH:context HASH{hash=PATH:value} PROGRAM:\n CONTENT[ \'bar\' ]\n }}\n'); + }); + it('parses a comment', function() { equals(astFor('{{! this is a comment }}'), "{{! ' this is a comment ' }}\n"); }); |