Open line-o opened 1 year ago
This will also make #22 easier to implement.
I think the issue here is with legacy template code, particularly for the data-template-function
and data-template-parameter-
parts of the proposal.
I'm not sure that the use case for renaming data-template
is as compelling as the other; there is no name collision problem that I can see; perhaps encourage data-template-function
but allow both?
Although it is extra work, is it worth considering considering data-template-arg
iff there is no data-template-parameter-arg
and there is no other function of that name?
I am aware that renaming data-template
will break existing templates as data-template-<parameter-name>
to data-template-parameter-<parameter-name>
will.
Do you think it is feasible to allow both? I consider the code that gathers the extra function parameters hot-code as it checks for the existence whenever a data-template
attribute is present on a node. But maybe we have enough time-budget left.
If it is too expensive, then I would lean towards leaving it as it is.
Although it is extra work, is it worth considering considering
data-template-arg
if there is no data-template-parameter-arg
and there is no other function of that name?
Do you want data-template-arg-<parameter-name>
as an alternative to data-template-parameter-<parameter-name>
or the above to allow both current and unified attribute names?
I agree with Tomos that I see no particular need for renaming data-template
. I think there are many reasons to rename data-target
though as it seems way too generic. I have to admit that I have no experience using the template module itself so my two cents are as good as any other's.
Do you want
data-template-arg-<parameter-name>
as an alternative todata-template-parameter-<parameter-name>
or the above to allow both current and unified attribute names?
Sorry for being unclear: "arg" in my example represents the parameter name, not the string arg
: I was following your syntax established under "Template Function Parameters" in the original description! :)
To restate, I was suggesting data-template-<parameter-name>
as a fall back to data-template-parameter-<parameter-name>
in the case where the latter is not supplied for a given template function with that parameter.
How about a - default - legacy mode that will accept both data-template
and data-template-<parameter-name>
?
When a user opts-in to the new strict(?) mode than only templates with data-template-function
and data-template-parameter-<parameter-name>
are acceptable.
Doing this would then enable to select any prefix to be used instead of data-template
. t-function
and t-parameter-<parameter-name>
would then become available and even namespaces would become availabe @t:*
.
Sounds like the right sort of approach: I would advise caution at treating namespace prefixes in the same way as prefixes within the attribute name, however - as I'm sure you already appreciate, they are not the same thing!
Status quo
At the moment we have most of the templating attributes share the prefix
data-template
There is two exceptionsdata-target
to identify a node/ slot where children of the calling element withdata-template="templates:include"
be placeddata-template
Proposed change
Disambiguate and unify
I would propose to unify those two to
data-template-target
making its purpose more obviousdata-template-function
for the same reasonTemplate function parameters
Additional parameters to template functions are also placed alongside other template attributes.
The parameter value
$arg
for a template function declared asmy:func($node, $model, $arg)
is defined in the template withdata-template-arg
. This can lead to hard to debug naming collisions.A hypothetical template function
my:clash($node, $model, $use-when)
would collide with the newly addeddata-template-use-when
(see #20).We can mitigate that by defining that additional template function parameter must be declared with
data-template-parameter-<name>
.