I'm wondering if there's any way to display all the possible outputs of either an If tag or a case tag, in Liquid. I'd like to be able to display the outputs for editing / debugging purposes.
For example, given:
Where allCases is a value so that the output would be:
This is the case when foo is 1.
This is the case when foo is 2.
N.B. while I used a special value for foo to illustrate the desired output, maybe it could be achieved with a filter, instead? e.g. [% case foo | showAll %]?
Attempted Solution:
I thought that the multi-case support might allow for this, so tried:
This is the case when foo is 1 or 0.
This is the case when foo is 2 or 0.
However, this only returns
This is the case when foo is 1 or 0.
i.e. it goes through the cases until it reaches the first matching case and then stops evaluating other cases. If tags have the same behaviour.
I know this could be achieved using separate if-statements, but was hoping to find a solution that didn't multiply the number of tags, in this way, as it is just for editing / debugging purposes, but is not needed for the final code.
Aucun commentaire:
Enregistrer un commentaire