developit / developit/htm

html string added in template form treated as string, not html

Open
#251 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
9k
Forks
181
PR merge metrics
No merged PRs in 30d

Description

```js
function Carousel(props) {
let images = props.images.split(",");
images.map(image => image.trim());

let mainImage = ``;

let minis = "";
images.forEach(imageUrl => {
minis = minis.concat(``)
})

console.log('a',images,minis)

console.log(html`


`)
}
```

specifically, notice these children:

```

${mainImage}
```

Even though they're identical input, one is converted to a string child, one is converted to a vdom object.

![image](https://github.com/developit/htm/assets/6391152/92347d06-6d46-48ba-93e3-10edac192595)

This is pretty annoying. For something this small, I don't want to create a preact element. I find it weird that this option isn't available. Am I missing something? Why does htm not allow this to be parsed as html but insist on keeping it as a string?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.