Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boolean and Null literals #911

Closed
s2b opened this issue Jul 19, 2024 · 1 comment
Closed

Boolean and Null literals #911

s2b opened this issue Jul 19, 2024 · 1 comment

Comments

@s2b
Copy link
Contributor

s2b commented Jul 19, 2024

Currently, it is dependent on the context if true/false/1/0 will be converted to booleans or if the values will remain as-is. This can lead to confusing behavior, for example for a TagBasedViewHelper:

<my:viewhelper disabled="true" />

This will lead to something like this:

<div disabled="true"></div>

However, one would expect the following result:

<div disabled="disabled"></div>
<!-- or -->
<div disabled></div>

However, we can't just convert true or false to boolean in all places because there are cases where you would want the string "true" instead. So we probably need some kind of syntax to decide explicitly, which type should be used.

One possibility is to solve this similarly to frontend frameworks (such as Svelte):

<my:viewhelper disabled="{true}" />

Same goes for null, which should be treated similarly to true and false.

@s2b s2b changed the title Boolean literals Boolean and Null literals Jul 20, 2024
@s2b
Copy link
Contributor Author

s2b commented Aug 6, 2024

First step to accomplish this would be to "block" some variable names by throwing a deprecation: true, false, null and _all.

The end result could look something like this:

<my:viewhelper disabled="{false}" />
<my:viewhelper disabled="{falsyVariable}" />
<my:viewhelper disabled="{someVariable as bool}" />
<my:viewhelper disabled="{myString == 'test'}" />

@s2b s2b closed this as completed Aug 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant