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 inline expressions for attributes (and in other places) #32

Open
mbostock opened this issue Oct 18, 2023 · 1 comment
Open

Support inline expressions for attributes (and in other places) #32

mbostock opened this issue Oct 18, 2023 · 1 comment
Labels
enhancement New feature or request question Further information is requested

Comments

@mbostock
Copy link
Member

Currently inline expression ${…} are only supported for node content. So you can’t do this:

```js
const link = "https://example.com";
```
This is a <a href=${link}>link</a>.

You can workaround it using Hypertext Literal like so:

```js
const link = "https://example.com";
```
This is a ${htl.html`<a href=${link}>link</a>`}.

I’m not immediately sure how we would support this. It might involve writing our own Markdown parser? Or at least pre-processing the content to remove the live code expressions before passing it to markdown-it? Presumably we could repurpose parts of Hypertext Literal to parse the HTML.

@mbostock mbostock added the enhancement New feature or request label Oct 18, 2023
@mbostock mbostock added this to the Early access milestone Nov 13, 2023
@mbostock
Copy link
Member Author

This is one of the trickiest outstanding questions in the CLI. If we do this, it probably requires radical changes to how we parse Markdown and generate HTML & JavaScript. We should decide whether we want to do that before Early Access.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant