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: fragments UX issues #28753
Comments
/cc @mkouba |
I agree with the above. I would add that {#fragment price}
something
{/fragment} Also for the |
@ia3andy Wouldn’t use of id be consistent with html? I would lean to use “” string for the id rather than what looks to varible reference. I would say I lean to agree that if we require BOTH to name something with $ AND add @checkedfragment and it is not possible today to use a variable with $ for data then $ should be sufficient. |
|
This is a theoretical argument at best. We don't want to support that, and the resulting template method would look like what,
I really don't see how a And also, what purpose or confusion could arise from removing the annotation? The typechecker is always going to validate that the template fragment exists when there's a
OK, but that's my point: it's confusing to users that they can't figure out exactly what is an expression or not. It's much more regular if users can rely on knowing that there are statements and expressions, and that expressions are strings, numbers, etc. So I'd advise sticking to strings for includes and IDs. It's funny that you're super strict when it comes to annotations on fragments, but super lax when it comes to what expressions are in Qute ;)
OK, so this looks even more confusing IMO, because it's very likely that we'll have a template parameter called If it's not an expression, then |
on @CheckedFragment being always required because there potentially could be a user having $ in their filenames...how about flipping it around and say that for those users that has that exceptional case they can add an annotation (i.e. @CheckedIdentifier or similar). Making the exception what you absolutely need an annotation for ? |
and why not |
Still a valid argument. We do not forbid using any character in the method name. Which implies that any valid java method name is OK. I don't think we should break compatibility unless we really must.
Fair enough. It's a user choice...
@FroMage I don't think I'm super lax here ;-). It's well defined. There are standalone expressions and there are sections that may treat params as expressions. Validation and interpretation of the parms is the business of a particular section. This allows for custom "rules" such as:
It's important to note that a fragment id can only match |
That's an interesting idea... actually, we don't need a new annotation. We could just add a safety switch to the |
Something like: And we could use the same strategy for the @maxandersen @FroMage @ia3andy ^ WDYT about this compromise? |
Well it seems to solve it all at once :) |
Well, Now, perhaps you are implying that IDs should be symbols, and thus be declared and used without quotes, which means they have their own namespace, separate for that of expressions. Like in Java methods, fields and classes have three separate namespaces? |
Which means we can get rid of |
Am I not clear enough? :D PS. Yes, because we'll have |
Well, great then! :) |
It doesn't atm. |
Well, I know, but we should still add features which aim to emulate this and keep it possible to add/define such a regular grammar at some point. |
- remove `@CheckedFragment` - introduce `@CheckedTemplate#ignoreFragments()` - change the syntax used to include a fragment; `{#include foo[bar] /}` -> `{#include foo$bar /}` - resolves quarkusio#28753
- remove `@CheckedFragment` - introduce `@CheckedTemplate#ignoreFragments()` - change the syntax used to include a fragment; `{#include foo[bar] /}` -> `{#include foo$bar /}` - resolves quarkusio#28753
- remove `@CheckedFragment` - introduce `@CheckedTemplate#ignoreFragments()` - change the syntax used to include a fragment; `{#include foo[bar] /}` -> `{#include foo$bar /}` - resolves quarkusio#28753
- remove `@CheckedFragment` - introduce `@CheckedTemplate#ignoreFragments()` - change the syntax used to include a fragment; `{#include foo[bar] /}` -> `{#include foo$bar /}` - resolves quarkusio#28753
- remove `@CheckedFragment` - introduce `@CheckedTemplate#ignoreFragments()` - change the syntax used to include a fragment; `{#include foo[bar] /}` -> `{#include foo$bar /}` - resolves quarkusio#28753
- remove `@CheckedFragment` - introduce `@CheckedTemplate#ignoreFragments()` - change the syntax used to include a fragment; `{#include foo[bar] /}` -> `{#include foo$bar /}` - resolves quarkusio#28753
- remove `@CheckedFragment` - introduce `@CheckedTemplate#ignoreFragments()` - change the syntax used to include a fragment; `{#include foo[bar] /}` -> `{#include foo$bar /}` - resolves quarkusio#28753
- remove `@CheckedFragment` - introduce `@CheckedTemplate#ignoreFragments()` - change the syntax used to include a fragment; `{#include foo[bar] /}` -> `{#include foo$bar /}` - resolves quarkusio#28753
- remove `@CheckedFragment` - introduce `@CheckedTemplate#ignoreFragments()` - change the syntax used to include a fragment; `{#include foo[bar] /}` -> `{#include foo$bar /}` - resolves quarkusio#28753
- remove `@CheckedFragment` - introduce `@CheckedTemplate#ignoreFragments()` - change the syntax used to include a fragment; `{#include foo[bar] /}` -> `{#include foo$bar /}` - resolves quarkusio#28753 (cherry picked from commit 9668146)
Description
#28476 introduced type-safe fragments, with the following syntax on the Java side:
The semantics is that a method named
foo$bar
refers to the fragment with identifierbar
defined in thefoo.html
file. The$
sign is used as separator to distinguish the template file and the identifier. This is required because using simply thefoo
part as the method name would introduce a clash with the containing template declaration, and using only thebar
part could also clash with a similarly named method defined for a template calledbar.html
(even if we distinguished it with@CheckedFragment(inside = "foo")
).In my opinion, the presence of
$
, being required due to the above, is enough to denote that we're talking about a fragment, and thus the@CheckedFragment
annotation is boilerplate and should be removed. @mkouba argues that it's more explicit, but IMO the$
stands out enough by itself.Now, on the other side of things, we have the following syntax for declaring fragments:
I think it's a mistake to denote the ID as something that looks like a symbol, because it's not consistent with other Qute expressions. Indeed, the Qute reference doesn't even mention symbols as a possible literal: https://quarkus.io/guides/qute-reference#literals so this looks like we're using the
price
variable as ID, which is very confusing. As such, I think the ID should be defined as a String value:Implementation ideas
No response
The text was updated successfully, but these errors were encountered: