-
-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add {{elseif}} sugar syntax #50
Conversation
@nathantreid: This is great work. Can you please resolve merge conflicts? And add also all changes to documentation (spacebars API, mention this also somewhere in guide, blaze itself, and so on)? We have now documentation in this repository, so you can just update this pull request. |
BTW, Handlebars seems to have else if. See also example in documentation. It seems the syntax is: {{else if isInactive}} And also: {{else unless isInactive}} Or in general it seems it can be
While I dislike this syntax, I see benefit of having it match Handlebars, and benefit of supporting any block helper. Implementation might be a bit trickier to implement, but this sugar is easy to do: {{#if foo}}
{{else something bar}}
{{/if}} Becomes: {{#if foo}}
{{else}}
{{#something bar}}
{{/something}}
{{/if}} @nathantreid, could you implement it this way? |
Yikes.... that seems kind of odd. Are we sure we want to think about handlebars at all? Honestly Handlebars doesn't seem that well designed to start with. |
For this particular feature I think I would. I would change what |
Also, this syntax seems to map nicely to the sugar we are trying to make. |
I also think that the {{else if}} syntax looks odd, perhaps we could put that up for a vote? |
It is not just a syntax here, but also a feature. So that you can use any block helper in this way. |
@nathantreid, I really love your work here and I think many people would like to see this in. But I also really like that the Handlebars syntax work with arbitrary block helpers. I think that block helpers are really powerful feature of Blaze and with allowing such chaining of them it would be really powerful. Currently block helpers were a bit strange to use because what if you had only two cases, but now you can potentially get multiple cases supported, not just true/false. Could you please update the pull request to support arbitrary block helpers? |
So something like this could then work: {{#tab title="Foo"}}
{{else tab title="Bar"}}
{{else tab title="Baz"}}
{{/tab}} And have a block helper which renders dynamically tabs, opens/closes them, etc. |
I'd be happy too, but I'm swamped right now IRL. If someone else wants to have a go at it, be my guest. Otherwise, I'll try to get to it as soon as I can. |
No worries. I just wanted to make sure we have a path forward. |
Any progress here? Anyone else wants to tackle this? |
This would be fantastic feature to have. @nathantreid still busy with things IRL? :) |
I cleaned |
With 2fa3cab I implemented the Handlebars syntax for chaining block tags. I am closing this pull request in favor of that. |
Released as 2.3.0. You have to update templating package. |
Implements #39.
Working example here: https://github.com/nathantreid/blaze-test-issue-39