developit / developit/htm

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

Offen
#251 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
JavaScript
Sterne
9k
Forks
181
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

```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?

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.