From 28840c993fda10d8d7185d75a49abb4226bd0adc Mon Sep 17 00:00:00 2001 From: wahid Date: Tue, 14 Feb 2017 13:11:49 +0700 Subject: [PATCH] fix string not rendered in its block --- lib/handlebars/helpers/block-helper-missing.js | 2 +- spec/blocks.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/handlebars/helpers/block-helper-missing.js b/lib/handlebars/helpers/block-helper-missing.js index e6d162f7f..3ba6ba1d7 100644 --- a/lib/handlebars/helpers/block-helper-missing.js +++ b/lib/handlebars/helpers/block-helper-missing.js @@ -5,7 +5,7 @@ export default function(instance) { let inverse = options.inverse, fn = options.fn; - if (context === true) { + if (context === true || (typeof context === 'string' && !inverse.hasOwnProperty('program'))) { return fn(this); } else if (context === false || context == null) { return inverse(this); diff --git a/spec/blocks.js b/spec/blocks.js index 2fbaee7cc..d91b41d2f 100644 --- a/spec/blocks.js +++ b/spec/blocks.js @@ -1,4 +1,10 @@ describe('blocks', function() { + it('string', function() { + var string = '{{#goodbye}}{{goodbye}}{{/goodbye}} {{#world}}{{world}}{{/world}}'; + var hash = {goodbye: 'Goodbye', world: 'Complex World'}; + shouldCompileTo(string, hash, 'Goodbye Complex World'); + }); + it('array', function() { var string = '{{#goodbyes}}{{text}}! {{/goodbyes}}cruel {{world}}!'; var hash = {goodbyes: [{text: 'goodbye'}, {text: 'Goodbye'}, {text: 'GOODBYE'}], world: 'world'};