XToolset
XToolset copied to clipboard
[Draft] Consider to add If ... else statement support.
The If ... else
statement would be a good solution in cases if the data model has for example an empty array, then it would be possible to display an information like 'No records...' or just omit the part of the template where there is a styled table generated by loop.
I think, this issue will assumse to add:
-
IfCell
, that matches#! IF [boolean]
-
ElseIfCell
, that matches into#! ELSE_IF [boolean]
-
ElseCell
, that matches into#! ELSE
-
EndIfCell
, that matches into#! END_IF
;
Questions to resolve first (until it is a draft):
- Will we handle if statements similar to the for-each (putting them on the end of the row)? - In that way, whole rows will be omitted if the condition doesn't pass
- Or want we use it in one line? (and how should it handle styles of omitted cells) - I rather won't do this in that way.
- Should we have something like "if filter" (I haven't a better name for that)? (for instance
## person.lastname ?? person.isLastnameHidden
) - IMO, it is an interesting idea - Will we allow nested if statements? IMO, we should 😄