-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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: shorter tag invocation #21855
Comments
/cc @mkouba |
In fact, you can currently access the |
- i.e. for params that define no key and contain only single part - also use Mapper instead of Map for the data passed to a template - Mapper value resolver has priority 15, i.e. is called before a generated value resolver - resolves quarkusio#21855 - related to quarkusio#21861
- i.e. for params that define no key and contain only single part - also use Mapper instead of Map for the data passed to a template - Mapper value resolver has priority 15, i.e. is called before a generated value resolver - resolves quarkusio#21855 - related to quarkusio#21861
Well, if I can access stuff that is outside the current scope in a tag, then I don't even need parameters. That's very counter-intuitive to my scoped programming background where a function can only access the data it's passed directly. |
A user tag is not a function, it's more like a "named include directive". It makes sense for literal arguments, e.g. |
Well no, I strongly disagree: if we allow access to stuff that's outside we can't typecheck them. I don't think they should behave as named include directives. |
First, type-checks are optional. Secondly, you can but you need to redefine the param declarations in the tag template - like you do in some vixen tags.
But they do, for a long time... which does not mean we can't change it now. But it would be a breaking change and there is no easy way to detect that someone used it the current/old way. |
They are optional, but if we turn them on we can't properly type-check if non-declared things are allowed to leak from the caller.
OK, but I'm not sure this usage is documented, is it? I certainly have never realised this was the case. |
But you don't care about the "leaked" things... and all the variables that are used in the tag can be redeclared.
Well, quite a few other things are not documented either because (1) the ref guide would be 2x longer, (2) we don't have resources to document everything... |
- i.e. for params that define no key and contain only single part - also use Mapper instead of Map for the data passed to a template - Mapper value resolver has priority 15, i.e. is called before a generated value resolver - resolves quarkusio#21855 - related to quarkusio#21861
I mean that if it's not documented, then it's never officially existed so nobody can possibly be using it, so we're free to change it ;)
I do, because they pollute my function, just like JS globals pollute local functions, they've been the bane of every language that has them. IIRC the last language that allowed the caller scope to leak into the callee was Emacs LISP: https://www.gnu.org/software/emacs/manual/html_node/elisp/Dynamic-Binding.html and yuck… ;) Please, let's not do that :) |
Come on ;-)
Your problem should be fixed in #22003. And it's not the same kind of problem because you don't specify the param on the call site which is not documented either... so you should not use it ;-) |
HAHA. OK, good point :) But given that it was not documented, I could only rely on my intuition to think about how I should handle optional parameters. |
Description
I found myself having lots of calls to tags that boiled down to:
And I wonder if we couldn't simplify those calls to:
That is: if we're passing a template parameter with no value (or no name, depending on how you look at it), we expand
<ident>
to<ident>=<ident>
.If I'm not mistaken, we can already currently pass a single parameter with no name, which ends up named as
it
, so we could expand the rules by saying that if the first parameter with no name is a single identifier (no dots, no complex expression) we make it available to the tag as bothit
and<ident>
?So, in our case, for a call of
{#likeAlbum album user/}
thealbum
value would be bound to bothit
andalbum
in the tag. I think that would make sense, no?Implementation ideas
No response
The text was updated successfully, but these errors were encountered: