-
Notifications
You must be signed in to change notification settings - Fork 149
Introduce <#unless> #376
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
Introduce <#unless> #376
Conversation
|
@miguel-s I am torn between keeping the By using a new I would also add tests in the |
|
@Malian great suggestions, thanks!
My reasons for going with
But I'm not married to the idea :)
Definitely. Wasn't very happy with my solution, so wanted to check my approach with you before investing more time into this. |
Co-authored-by: Malian <deronmalian@gmail.com>
|
I think sticking with ast.if makes sense for the reasons @miguel-s listed. I'd originally thought inverting the condition was the way to go (inspired by elixir's unless), but using the else block is a clever solution. |
Co-authored-by: Lloyd Ramey <lnr0626@users.noreply.github.com>
|
One downside of using if true do
1
else
2
else
3
endwill raise: I'm not sure if we're already validating duplicated Regarding |
😱 I was glad to believe this did not exist!
I suggest not allow this at the first stage. If we receive feedback from users who want to add it, we will be able to consider supporting it too.
No we don't. The following case is not validated too: <#if {true}>
IF
<#else>
ELSE
<#elseif {true}>
ELSEIF
</#if> |
Agree. It might be even positive to not support it. We can always revisit this it if we get enough feedback.
I've looked and not been able to find any case like this. @Malian can you think of any place this could happen? |
With the current implementation I believe we cannot arrive in that specific invalid state. In the EEXEngine we have that piece of code that cannot have more than one {:if, [generated: true], [condition, [do: if_buffer, else: else_buffer]]}Nevertheless, a code that do not respect the |
|
@miguel-s It is easy to validate both cases (see my branch https://github.com/Malian/surface/tree/validate-wrong-if-elseif-else-constructs). That being said, I am not sure if we should merge it as it make the compiler file more complex and the work that @lnr0626 is doing on #378 will help us to have a more maintainable code, so I suggest to wait until #378 is merged before tackling the validations. WDYT? |
Agreed. 👍 |
msaraiva
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@miguel-s this is good to go!
* surface-next: Remove `phx_` prefix from props (surface-ui#384) Remove code for embedded interpolation inside strings Introduce <#unless> (surface-ui#376) Introduce the concept of root properties (surface-ui#382) Warn on invalid prop/data defaults (surface-ui#374) Deprecated unquoted strings (surface-ui#379) Convert embedded interpolation (surface-ui#380) Introduce <#raw> and deprecate <#Raw> (surface-ui#377)
Related to #340