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

Pre RFC / Feature Request: (De)structuring #553

Open
NullVoxPopuli opened this issue Oct 24, 2019 · 15 comments
Open

Pre RFC / Feature Request: (De)structuring #553

NullVoxPopuli opened this issue Oct 24, 2019 · 15 comments

Comments

@NullVoxPopuli
Copy link
Sponsor Contributor

NullVoxPopuli commented Oct 24, 2019

As far as I know, there is no syntactic meaning in glimmer for { } (single curlies).
So, without diving in at trying to implement this myself, it seems like we have room to implement something like the following:

{{!-- Before --}}
<Button @variant='primary' as |yieldedHash|>
  <yieldedHash.Icon />
</Button>

{{!-- After --}}
<Button @variant='primary' as |{ Icon }|>
  <Icon />
</Button>

and

{{!-- Before --}}
<Button @variant={{@variant}} @size={{@size}} @onClick={{this.onClick}}>
  {{@text}}
</Button>

{{!-- After -- I don't think this is the right way to do this, cause it's semantically weird --}}
<Button { @variant @size this.onClick }>
  {{@text}}
</Button>

Thoughts?

@lifeart
Copy link

lifeart commented Oct 24, 2019

<Button @variant="primary" as | ( Icon Image ) ( Spinner ) |>
  <Icon />
  <Image />
  <Spinner />
</Button>

@NullVoxPopuli
Copy link
Sponsor Contributor Author

| ( Icon Image ) ( Spinner ) |

I thought () already imply helper?
hmm. idk. as is weird.

@lifeart
Copy link

lifeart commented Oct 24, 2019

or we can finally drop {{, }} and use {, } :)

@NullVoxPopuli
Copy link
Sponsor Contributor Author

NullVoxPopuli commented Oct 24, 2019

I know that's a troll, but, for others who may not know:

that would introduce ambiguity with what this question/issue is about.
We want things more clear, and easily differentiable, not less.

{{}} always means mustache expression, which is (in strict):

  • value expression
    • which could be a helper invocation

to reduce {{}} to { } means that we'd need to, at runtime, determine usage / intent. not ideal :(

@lifeart
Copy link

lifeart commented Oct 24, 2019

Svelte use mustache and ‘{‘

@monovertex
Copy link

{{!-- Before --}}
<Button @variant={{@variant}} @size={{@size}} @onClick={{this.onClick}}>
  {{@text}}
</Button>

{{!-- After -- I don't think this is the right way to do this, cause it's semantically weird --}}
<Button { @variant @size this.onClick }>
  {{@text}}
</Button>

We don't use angle bracket components in our project yet, so I'm not sure if this conflicts with anything, but what about dropping the curlies?

{{!-- After --}}
<Button @variant @size this.onClick>
  {{@text}}
</Button>

Basically the shorthand property value feature, just consider <Button and > as the opening and closing curlies.

@NullVoxPopuli
Copy link
Sponsor Contributor Author

but what about dropping the curlies?

This already means positional params though.

@monovertex
Copy link

This already means positional params though.

Right, my bad, forgot about positional params, we never use them for our components 😅

@ro0gr
Copy link

ro0gr commented Oct 25, 2019

This already means positional params though.

I don't think we have positional params for <AngleBrackets, do we?

@NullVoxPopuli
Copy link
Sponsor Contributor Author

NullVoxPopuli commented Oct 25, 2019

I don't think we have positional params for <AngleBrackets, do we?

Not with the Glimmer Component manager, but we can make component managers that support positional params. I've been wanting to dig in to this for control flow, for things like ember-animated, or other control-flow logic (maybe like with async-data loading at the component level for managing intermediate / placeholder state).

There is a write up on all that here: https://github.com/tildeio/ember-control-flow-component

Though, maybe I still misunderstand, and maybe not having positional in angle brackets is a real limitation, and not just a choice to enhance clarity in the modern era?. idk.

@NullVoxPopuli
Copy link
Sponsor Contributor Author

NullVoxPopuli commented Oct 25, 2019

yup, I was wrong about the positional thing in angle brackets:
image

Thanks @rwjblue and @locks! <3

Further important info from @locks:

the glimmer component manager does not enable the positional params capability
it's less a limitation and more a design choice
because the ember component manager does have to enable it

@locks
Copy link
Contributor

locks commented Oct 25, 2019

Svelte use mustache and ‘{‘

Svelte does not use mustache.

@lifeart
Copy link

lifeart commented Oct 25, 2019

@locks https://github.com/sveltejs/svelte/blob/master/src/compiler/parse/state/mustache.ts

It's kinda Mustache

Why we need to continue write {{ instead of { just because of handlebars history?

@robclancy
Copy link

robclancy commented Nov 14, 2019

{{!-- Before --}}
<Button @variant={{@variant}} @size={{@size}} @onClick={{this.onClick}}>
  {{@text}}
</Button>

{{!-- After -- I don't think this is the right way to do this, cause it's semantically weird --}}
<Button { @variant @size this.onClick }>
  {{@text}}
</Button>

We don't use angle bracket components in our project yet, so I'm not sure if this conflicts with anything, but what about dropping the curlies?

{{!-- After --}}
<Button @variant @size this.onClick>
  {{@text}}
</Button>

Basically the shorthand property value feature, just consider <Button and > as the opening and closing curlies.

This was my first thought when wanting to be able to remove the redundancy. Would be sexy. However would also be confusing for new people which is why a more JS like syntax should be used (if anything) imo.

@wagenet
Copy link
Member

wagenet commented Jul 23, 2022

Leaving this open for now since it's referenced in @NullVoxPopuli's meta issue.

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

7 participants