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

Qute: consider renaming one form of with to let #8749

Closed
FroMage opened this issue Apr 22, 2020 · 4 comments
Closed

Qute: consider renaming one form of with to let #8749

FroMage opened this issue Apr 22, 2020 · 4 comments
Assignees
Labels
area/qute The template engine kind/enhancement New feature or request
Milestone

Comments

@FroMage
Copy link
Member

FroMage commented Apr 22, 2020

This is a with:

{#with item.parent}
  <h1>{name}</h1>  
  <p>{description}</p> 
{/with}

It changes the default scope.

This form, however, should be called let:

{#with item.parent as myParent} 
  <h1>{myParent.name}</h1>
{/with}

There's no equivalent to this form in JS or VB, both of which support with. Perhaps we could event support the following form?

{#let item.parent as myParent,
  item.count() as count} 
  <h1>{count}: {myParent.name}</h1>
{/let}
@FroMage FroMage added kind/enhancement New feature or request area/qute The template engine labels Apr 22, 2020
@quarkusbot
Copy link

/cc @mkouba

@mkouba
Copy link
Contributor

mkouba commented Apr 23, 2020

This form, however, should be called let
There's no equivalent to this form in JS or VB, both of which support with.

Well, we don't need an equivalent in JS or VB and IMO it reads ok.

I would introduce a new tag called let that would allow users to specify a map, i.e. something like {#let myParent=item.parent count=item.count}. WDYT?

@mkouba
Copy link
Contributor

mkouba commented Apr 23, 2020

Ah, we actually already have the SetSectionHelper but it's not mentioned in the docs. I'll add the 'let' alias:

{! this works now !}
{#set myParent=item.parent count=item.count} 
  <h1>{count}: {myParent.name}</h1>
{/set}

{! we will add the "let" alias !}
{#let myParent=item.parent count=item.count} 
  <h1>{count}: {myParent.name}</h1>
{/let}

@mkouba mkouba self-assigned this Apr 23, 2020
@FroMage
Copy link
Member Author

FroMage commented Apr 23, 2020

Err… OK, but I'm confused as to the syntax here. In the case of with we have as and here it's =. Why the difference? Also, aren't parameters separated with commas?

@gsmet gsmet closed this as completed in c4e99a9 Apr 23, 2020
gsmet pushed a commit to gsmet/quarkus that referenced this issue Apr 23, 2020
@gsmet gsmet added this to the 1.4.1.Final milestone Apr 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/qute The template engine kind/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants