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: tag parameter validation #21859

Open
FroMage opened this issue Dec 1, 2021 · 5 comments
Open

Qute: tag parameter validation #21859

FroMage opened this issue Dec 1, 2021 · 5 comments
Labels
area/qute The template engine kind/enhancement New feature or request

Comments

@FroMage
Copy link
Member

FroMage commented Dec 1, 2021

Description

ATM we can declare tag parameters like this:

{@java.lang.Boolean img}
{@java.lang.Integer size}
{@fr.epardaud.model.User it}

<!-- FIXME: there appears to be a size value coming from outer space -->
<span class="user-link" title="{it.userName} currently has {it.reputation} reputation points">
<a href="{uri:Users.view(it.userName)}">
{#if img??}
{it.reputation}
{/if}
{#if img??}
{#gravatar it.email size=size.or(20) default='mm' /}
{/if}
{it.userName}</a></span>

But we have the following issues:

  • I tried using {@boolean img} and got an error. I guess the wrapper type works fine as a workaround, but perhaps we could relax this and make it an alias?
  • Call-sites are not validated: we don't verify that we call this tag with {user userValue img=booleanValue/}
  • Default values are not supported: I can't call this with {user userValue/} without using img?? in the tag, and if we do call-site validation this might be disallowed because one parameter will be missing. So perhaps we need to allow default parameter values:
{@java.lang.Boolean img=false}
{@java.lang.Integer size=20}
{@fr.epardaud.model.User it}

<!-- FIXME: there appears to be a size value coming from outer space -->
<span class="user-link" title="{it.userName} currently has {it.reputation} reputation points">
<a href="{uri:Users.view(it.userName)}">
{#if img}
{it.reputation}
{/if}
{#if img}
{#gravatar it.email size=size default='mm' /}
{/if}
{it.userName}</a></span>

Implementation ideas

No response

@FroMage FroMage added the kind/enhancement New feature or request label Dec 1, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Dec 1, 2021

/cc @mkouba

@gbourant
Copy link

gbourant commented Jun 5, 2024

I'm making a Qute component library, the tag section would fit perfect if it had validation like a normal template does.

@mkouba
Copy link
Contributor

mkouba commented Jun 6, 2024

I'm making a Qute component library, the tag section would fit perfect if it had validation like a normal template does.

Do you mean the call site validation?

@mkouba
Copy link
Contributor

mkouba commented Jun 6, 2024

  • I tried using {@boolean img} and got an error. I guess the wrapper type works fine as a workaround, but perhaps we could relax this and make it an alias?

I believe that this was fixed long time ago, i.e. you can use {@boolean img}.

  • Call-sites are not validated: we don't verify that we call this tag with {user userValue img=booleanValue/}

Yes, this one is a little bit more complicated because we don't have a way to validate sections in a template yet. It's on my TODO though ;-).

  • Default values are not supported: I can't call this with {user userValue/} without using img?? in the tag, and if we do call-site validation this might be disallowed because one parameter will be missing. So perhaps we need to allow default parameter values:

This should be supported, i.e. you should be able to use {@boolean img=false}.

@gbourant
Copy link

gbourant commented Jun 6, 2024

I'm making a Qute component library, the tag section would fit perfect if it had validation like a normal template does.

Do you mean the call site validation?

Yes! :)

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

3 participants