Skip to content
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

Support map literals #63

Open
kwin opened this issue Jun 19, 2018 · 6 comments
Open

Support map literals #63

kwin opened this issue Jun 19, 2018 · 6 comments

Comments

@kwin
Copy link

kwin commented Jun 19, 2018

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

${'key1':'value1','key2':'value2'}
@henrykuijpers
Copy link

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?

@kwin
Copy link
Author

kwin commented Jan 15, 2020

This would rather be a question for @raducotescu. Any plans on a new HTL spec version where this could be included?

@tripodsan
Copy link
Contributor

tripodsan commented Jan 16, 2020

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.

@henrykuijpers
Copy link

@raducotescu any update?

@raducotescu
Copy link
Member

@henrykuijpers, it's something we're discussing internally. As soon as we reach a conclusion we will post it here.

@paulochang
Copy link
Contributor

Any way to vote on this proposal? I am also in favor, and agree JSON syntax seems like the way to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants