Open seanwestfall opened 5 years ago
Hey @phillipskevin Responded in the original pull request comment, above your response.
Thanks @seanwestfall for explaining! I like the idea of an elseIf
helper. This would probably need to work similar to the switch
helper so that the elseIf
is only evaluated if the if
was falsey.
If it works similar to if
then both <p>
tags will be displayed for something like:
{{#if(animal.barks)}}
<p>The animal barks</p>
{{#elseIf(animal.isADog)}}
<p>The animal is a dog</p>
{{/if}}
when the data looks like:
{
animal: { barks: true, isADog: true }
}
Hey @phillipskevin Sorry for taking so long to get back to you, here is what I envision: (code is from the homepage)
Compare to the original:
The reason being it'll make syntax like this from the home page a little more intuitive. I realize after going through the source that an "else if" is pretty much exactly like an "if" in succession, but most languages and frameworks support an if / else if / else pattern when setting up a succession of condition statements.
Is there anyway we could possibly do user group research to know if developers prefer this pattern over what's currently there?
Also, I added a test file, though it's a copy of the if test, which is what it'll look like mostly likely.