Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

When returning a string from a conditional check Parser cuts averything after a "-" #77

Open
Humberd opened this issue Feb 22, 2018 · 1 comment

Comments

@Humberd
Copy link

Humberd commented Feb 22, 2018

It should return vis-blue when selected locale is the same as in the list

<:each value="{locales}">
    <table growx="true"
           maxwidth="500"
           onclick="selectLocale"
           id="{value}"
           row="true">
        <label align="left"
               growx="true"
               color="{? $getCurrentLocale == {value} ? 'vis-blue' : 'white'}"> <!-- here -->
            @languages/{value}
        </label>
    </table>
</:each>

Instead I receive:

Exception in thread "LWJGL Application" com.github.czyzby.lml.util.LmlParsingException: Error occurred during parsing near line 24 of the original file: "locale-selector.lml" during parsing template part: "'each' macro result" on line: 9 of its content. Template part is most likely an evaluated macro or argument result, extracted from the original template.
REASON: Unable to obtain color with name: 'vis
	Due implementation of the parser, the real problematic line might SLIGHTLY vary from the given line number(s), but exception message should be clear enough to find the actual error.
	Currently parsed template part:
6  |VALID|            row="true">
7  |VALID|         <label align="left"
8  |VALID|                growx="true"
9  |ERROR|                color="{? 'en' == 'en' ? 'vis-blue' : 'white'}">
10 |     |             @languages/en
11 |     |         </label>
12 |     |     </table>

	This template part was most likely evaluated during parsing this original template part (if a macro or an argument ends on this line, its content most likely causes the error): 
21 |VALID| </:each>
22 |VALID|         </table>
23 |VALID|     </dialog>
24 |ERROR| </:noop>
25 |     | 

@edit
Even simple condition returns "vis

<label>
    {? 4 > 1 ? "vis-blue"}
</label>
@czyzby
Copy link
Owner

czyzby commented Feb 23, 2018

It might have a problem with the - inside the string (basically tries to execute "'vis" - "blue'"). The condition/equation parser is a bit magical - I wrote it a long time ago and it might have more edge cases that are not covered. ;) For now, rename the color in your Skin to something without a dash or assign vis-blue to a parameter that you can safely inject. I'll try to look into it before the next release.

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

No branches or pull requests

2 participants