summaryrefslogtreecommitdiffstats
path: root/spec/partials.js
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2015-09-01 00:48:20 -0500
committerkpdecker <kpdecker@gmail.com>2015-09-01 00:48:20 -0500
commite7a64f018ca541a7e0ac8ab2108ed86820bb47b1 (patch)
tree9680f623156fad643bae1a38ae9de425d8fbd583 /spec/partials.js
parent0f5061e44524a431659f0665c4cd7557af9525a0 (diff)
parent6c45f49b24d63acda37072df464bd670af97a072 (diff)
downloadhandlebars.js-e7a64f018ca541a7e0ac8ab2108ed86820bb47b1.zip
handlebars.js-e7a64f018ca541a7e0ac8ab2108ed86820bb47b1.tar.gz
handlebars.js-e7a64f018ca541a7e0ac8ab2108ed86820bb47b1.tar.bz2
Merge branch 'decorators'
Diffstat (limited to 'spec/partials.js')
-rw-r--r--spec/partials.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/partials.js b/spec/partials.js
index 314cca2..f3283ba 100644
--- a/spec/partials.js
+++ b/spec/partials.js
@@ -257,6 +257,45 @@ describe('partials', function() {
});
});
+ describe('inline partials', function() {
+ it('should define inline partials for template', function() {
+ shouldCompileTo('{{#*inline "myPartial"}}success{{/inline}}{{> myPartial}}', {}, 'success');
+ });
+ it('should overwrite multiple partials in the same template', function() {
+ shouldCompileTo('{{#*inline "myPartial"}}fail{{/inline}}{{#*inline "myPartial"}}success{{/inline}}{{> myPartial}}', {}, 'success');
+ });
+ it('should define inline partials for block', function() {
+ shouldCompileTo('{{#with .}}{{#*inline "myPartial"}}success{{/inline}}{{> myPartial}}{{/with}}', {}, 'success');
+ shouldThrow(function() {
+ shouldCompileTo('{{#with .}}{{#*inline "myPartial"}}success{{/inline}}{{/with}}{{> myPartial}}', {}, 'success');
+ }, Error, /myPartial could not/);
+ });
+ it('should override global partials', function() {
+ shouldCompileTo('{{#*inline "myPartial"}}success{{/inline}}{{> myPartial}}', {hash: {}, partials: {myPartial: function() { return 'fail'; }}}, 'success');
+ });
+ it('should override template partials', function() {
+ shouldCompileTo('{{#*inline "myPartial"}}fail{{/inline}}{{#with .}}{{#*inline "myPartial"}}success{{/inline}}{{> myPartial}}{{/with}}', {}, 'success');
+ });
+ it('should override partials down the entire stack', function() {
+ shouldCompileTo('{{#with .}}{{#*inline "myPartial"}}success{{/inline}}{{#with .}}{{#with .}}{{> myPartial}}{{/with}}{{/with}}{{/with}}', {}, 'success');
+ });
+
+ it('should define inline partials for partial call', function() {
+ shouldCompileToWithPartials(
+ '{{#*inline "myPartial"}}success{{/inline}}{{> dude}}',
+ [{}, {}, {dude: '{{> myPartial }}'}],
+ true,
+ 'success');
+ });
+ it('should define inline partials in partial block call', function() {
+ shouldCompileToWithPartials(
+ '{{#> dude}}{{#*inline "myPartial"}}success{{/inline}}{{/dude}}',
+ [{}, {}, {dude: '{{> myPartial }}'}],
+ true,
+ 'success');
+ });
+ });
+
it('should pass compiler flags', function() {
if (Handlebars.compile) {
var env = Handlebars.create();