Open kwin opened 6 years ago
Any progress or additional thoughts on this, @kwin ?
I'd love to see this make the Sightly/HTL asap, as we often end up creating backend logic for something as simple as adding a query string parameter to a URL.
It would be nice if a JSON-like syntax is supported, even though that could be tricky since { and } already have a special meaning. Especially since we're already supporting a JavaScript array syntax ([1, 2, 3]).
Are there any technical complications in using the JSON notation that you suggested? Or has this just not been a priority yet?
This would rather be a question for @raducotescu. Any plans on a new HTL spec version where this could be included?
I think it should be the normal javascript object initializer, allowing unquoted keys, and references to other variables. eg:
${{key1:'value1', 'key2':'value2'}}
// or
<li data-sly-list="${articles}" data="${{key1:'value1', key2:42, key3:item}}" ></li>
as a workaround, you can define the object in your use class.
@raducotescu any update?
@henrykuijpers, it's something we're discussing internally. As soon as we reach a conclusion we will post it here.
Any way to vote on this proposal? I am also in favor, and agree JSON syntax seems like the way to go.
Currently it is not possible to create map literals (consisting of several key/value pairs) in HTL expression language. This would be especially handy for passing request attributes (see https://issues.apache.org/jira/browse/SLING-5812) which may now be given to
data-sly-include
. Currently one needs to have some backing code in JavaScript or Java to be able to use that option.Maybe JSON notation would work