czyzby/gdx-lml

Conditional macro <:if:else/> not work with "test" attribute

jajanjawa opened this issue · 3 comments

my lml:

<:if test="{platform}=Desktop"><textfield id="email" /><:if:else /><selectbox id="email"/></:if>

it's say: No macro tag provider found for name: if:else

Yeah, I think the parser is pretty naive when looking for the else tag and will only accept <:if:else/> (without the space). That's the current workaround - remove the space and it should just work. I'll look into it.

Damn. I'm pretty sure I used a regex to detect this if-else "separator" once, but it looks like switched it to a split by string literal at some point for speed, GWT compatibility or whatever reason. Since LibGDX 1.9.5 seems bugged (GWT fails to compile), I'll wait until 1.9.6 and try fix it somehow before the release. Omit the space for now.

(If you're wondering why the hell do I need regex to split text in the first place instead of just parsing and handling XML tags like a human being - macros work on plain text rather than parsed XML tags, as they manipulate the templates' structures. Conditional macros have to detect the point at which decide what's getting parsed when condition evaluates to true, and what's getting parsed otherwise.)

Oh, God. The workaround feels dirty in so many ways. But yeah, in 1.9.6 you will be able to use no space or a single space in the else tag.