You wrote:
= hb 'if content.condition1' do
= hb 'if content.condition2' do
%p Some paragraph
= hb 'else'
%p another paragraph
= hb 'else'
%p third paragraph
Correct code:
= hb 'if content.condition1' do
= hb 'if content.condition2' do
%p Some paragraph
= hb 'else'
%p another paragraph
= hb 'else'
%p third paragraph
The reason for this is actually a haml syntax issue, not a hamlbars one. You cannot nest under a ruby statement unless you're passing in a block. Since {{else}}
is not a handlebars block statement you don't pass in a block. Haml would help a lot if it threw the a similar error to the one it throws when you try and nest under plain text.
seems like it'd be trivial to make the first case work (which is much more readable). if the
expression
inexpress()
is equal to'else'
then you don't need to output demarcation.lastwhat do you think? would you accept a small patch that enabled the follow?
= hb 'if content.condition1' do
= hb 'if content.condition2' do
%p Some paragraph
= hb 'else' do
%p another paragraph
= hb 'else' do
%p third paragraph
shouldn't have any legacy code issues since this will only affect block expression that match 'else' (which at the moment, there should be exactly none of since it results in invalid handlebars syntax).
thanks!