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 attribute splat operator #91

Open
WebFreak001 opened this issue Jun 17, 2021 · 0 comments
Open

support attribute splat operator #91

WebFreak001 opened this issue Jun 17, 2021 · 0 comments

Comments

@WebFreak001
Copy link
Contributor

WebFreak001 commented Jun 17, 2021

For a variable of type (string, string)[] or string[string] it should be possible to apply all items in the array as attributes for any tag such that the keys (or first items in tuples) are the attribute names and the values (or second items in tuples) are the attribute values.

So for a given variable like this

string[string] myAttrs = ["src": "image.png", "alt": "cool image", "title": "this is a cool image"];

it would be possible to splat it onto some kind of element, let's say a <div> element, for example with a syntax that could look like this:

div(*myAttrs, extra="attributes here")

resulting in this HTML: (attribute order not guaranteed with AA but should be guaranteed with list of tuples)

<div src="image.png" alt="cool image" title="this is a cool image" extra="attributes here">

This should be generic to work with any input ranges of key/value pairs or 2 item tuples as well as any value types. For attributes that are specified multiple times, or implicitly from other syntax, the same rules as typing out all the attributes now should apply. (e.g. combining .dot style class names with class attributes)

See https://forum.dlang.org/post/[email protected]

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

1 participant