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

Dynamic tag name / prop name #109

Closed
dy opened this issue Jul 28, 2019 · 4 comments
Closed

Dynamic tag name / prop name #109

dy opened this issue Jul 28, 2019 · 4 comments
Labels
enhancement New feature or request wontfix This will not be worked on

Comments

@dy
Copy link

dy commented Jul 28, 2019

Calculated tag name or props:

html`<page-${page} />`
html`<div#${id}.${className} />`
html`<div class="${'a'} ${'b'}"/>`

aren't possible with htm now.

That's a feature-request.

@dy dy changed the title Dynamic component name Dynamic tag name / prop name Jul 28, 2019
@jviide
Copy link
Collaborator

jviide commented Jul 29, 2019

This has been implemented & merged in #93. Edit: I was wrong, see update below.

@jviide jviide closed this as completed Jul 29, 2019
@jviide
Copy link
Collaborator

jviide commented Jul 29, 2019

Nope, sorry, I was thinking of attribute values!

@jviide jviide reopened this Jul 29, 2019
@jviide
Copy link
Collaborator

jviide commented Jul 29, 2019

@dy Currently there is no special syntax for string interpolation in tag names, but html`<${"page-" + page} />` should work.

The syntax in your last example (html`<div class="${'a'} ${'b'}"/>`) has been implemented in #93 and merged to master.

@developit
Copy link
Owner

Hiya - I really don't think HTM should be extended with hyperscript-style syntax. For that, use hyperscript.

Calculated tag names are both confusing and of extremely limited use - they can't represent components because the concatenated value is always a String, so they are limited to representing two pieces of the same string. For that, @jviide's example is sufficient and easy to understand.

@developit developit added enhancement New feature or request wontfix This will not be worked on labels Jul 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants