Skip to content
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

Support chained else #150

Open
samselikoff opened this issue Dec 27, 2014 · 7 comments
Open

Support chained else #150

samselikoff opened this issue Dec 27, 2014 · 7 comments

Comments

@samselikoff
Copy link
Contributor

Is it possible to animate between more than one if-else block, something like a case statement?

I'm essentially trying to replicate the if example from the docs, but with more than two options in the dropdown.

@ef4
Copy link
Collaborator

ef4 commented Dec 27, 2014

The best way to do this is to string several separate liquid-if's together.

{{#liquid-if firstMode}}
{{/liquid-if}}

{{#liquid-if secondMode}}
{{/liquid-if}}

{{#liquid-if thirdMode}}
{{/liquid-if}}

@samselikoff
Copy link
Contributor Author

I did this, but maybe I didn't get the transitions right. The content that was transitioning in was coming in from the bottom-right corner. I had something like

{{#liquid-if firstMode class='first-mode'}}
{{/liquid-if}}

{{#liquid-if secondMode class='second-mode'}}
{{/liquid-if}}

{{#liquid-if thirdMode class='third-mode'}}
{{/liquid-if}}

and the transitions

this.transition(
  this.hasClass('first-mode'),
  this.use('toRight'),
  this.reverse('toLeft')
);

this.transition(
  this.hasClass('second-mode'),
  this.use('toRight'),
  this.reverse('toLeft')
);

this.transition(
  this.hasClass('third-mode'),
  this.use('toRight'),
  this.reverse('toLeft')
);

@ef4
Copy link
Collaborator

ef4 commented Feb 13, 2015

We can take advantage of the new chained else helper support in htmlbars to make this easier.

handlebars-lang/handlebars.js#892

@ef4 ef4 changed the title Example for multiple ifs? Supposed chained else Feb 13, 2015
@ef4 ef4 changed the title Supposed chained else Support chained else Feb 13, 2015
@green-arrow
Copy link

@ef4 has anyone given this more thought / worked any on this?

@ef4
Copy link
Collaborator

ef4 commented Jul 15, 2015

We haven't made any new progress on this. Would be happy to support someone with time to experiment.

@Cryrivers
Copy link
Contributor

i think now you can just use normal {{#if }} {{else if}} {{else}} in a liquid-bind block

@ef4
Copy link
Collaborator

ef4 commented May 19, 2016

You can, and that works well for many use cases, but it's not exactly the same as what a full liquid-each could do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants