-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
shorter templating attributes prefix #22
Comments
I've never found the That said, if we're going to do it let's do it properly then: I'd go for the shortest version
|
I would imagine that we need to stay with the |
The current state does not bother me in the least. The advantages @line-o describes at the top - compatibility with HTML5 and semantic clarity of the name - are important and worth preserving. |
OK, I hear you. Thanks for the feedback. So any shortening will only be something that one might be allowed |
About the HTML5 compatibility. This will really only affect documents where the template attributes have not |
In my applications, at least, templating attributes are solely used for server-side processing and do not need to be sent to the client. |
This feature will not be included in the next major version but can be part of a later release. |
It seems to me that there are two cases:
|
@yamahito yes,
Can we make namespaces configurable as we can with prefixed attribute-names? |
I am in the team that uses JS-specific CSS-classes. |
I'm not 100% clear on what you mean here by "configurable"? |
As I understood the feedback, some want to keep template specific attributes as data-attributes. The start and end delimiters are changed so that the templates can be inserted directly. To continue using "data-template"templates:render(
<html>
<body data-template="templates:if-parameter-set" data-template-param="data">[[data]]</body>
</html>,
map { "data": "oversimplified example" },
map {
$templates:CONFIG_ATTRIBUTE_PREFIX : "data-template",
$templates:CONFIG_START_DELIMITER: '\[\[',
$templates:CONFIG_END_DELIMITER: '\]\]'
}
) To use
|
@yamahito Thinking about it having all templating related attributes in a separate, known namespace would make checks and filtering easier. But you could definitely only have one strategy per rendering, either with or without namespaces attributes. |
Your Ideal Solution
At the moment the attributes used to declare functions, variables and other options are prefixed with
data-template
. This serves two purposes:data
-attributes, the templates themselves are valid HTML5 documents (or document fragments for includes)data-template
may be verbose but makes it also pretty clear that this specific attribute has to do with templatingNow if we look at a simple template this leads to quite a lot of templating related markup in comparison to the actual contents.
In order to shorten the prefix we could choose to sacrifice one or two of the above principles by choosing a shorter prefix:
data-tpl
data-t
tpl
The last option would yield:
Template attributes that are not yet prefixed like
data-target
anddata-start
,data-end
should be prefixed as well. And the attribute declaring the template function to use should include a keyword indicating that.function
,handler
,f
,fun
,func
are options.Any Alternative Options
Even shorter prefix with just
t
is possible. Shorter built-in function names can further reduce the clutter.There is also the possibility to declare a namespace that is bound to the templating name. But I can foresee this would create a lot of problems down the line.
Additional Context
This is part of the effort to release the next major version #17
The text was updated successfully, but these errors were encountered: