|
f53eeeb1db28818c525f3eae17d0860a
|
"Case" not working as expectedby wideeye - Member - 10:13AM, Oct 27, 2006 |
|
Hi The Case statement in liquid isn’t functioning as I expected. Here’s a quick code snippet:
I would expect this to show “menswear” if the collection handle equalled “menswear-jackets”. Unfortunately it outputs “womenswear”. Can anyone explain how this is happening? Also, I come from more traditional programming background, and I’m used to being able to have multiple conditions that “drop through” each other, so the above could be written:
... is this possible with liquid?? Cheers |
|
|
....or some sort of function to do something like:
It’s frustrating not being able to even access basic functions like this! I realise I’m probably trying to bend shopify into doing something it shouldn’t do, but it would be good if there was at least a temporary work around!
|
|
|
The problem is that ptitle will be in scope of the case block. I changed liquid so that assign now assigns global variables so the code you pasted should work when we deploy shopify next time ( will probably be today ) note that assign’s syntax is ---
Tobias Lütke
|
|
|
This is now in. ---
Tobias Lütke
|
|
|
Hmmm… the {% else %} catch all seems to be catching it every time!
|
|
|
Wideeye: Thanks for the great report! Sure enough you unearthed a obscure bug in liquid which would execute else statements but discard their output if they are not needed. This of course always lead to the assign to run. This should now be fixed ---
Tobias Lütke
|
wideeye
Member
01:11PM, Oct 27, 2006