imba / imba.io

📄The official website of Imba
http://imba.io
MIT License
80 stars 37 forks source link

Need an idiomatic way to insert HTML text #192

Open lacikawiz opened 3 years ago

lacikawiz commented 3 years ago

Currently, the variables and string constants are inserted using the innerText property. This causes HTML encoded elements like   or &raquo to show up as the code, and not as a space or » character.

There's a hacky way to make that happen using the innerHTML property, like this: <th innerHTML="&raquo;">

However, this is not in the documentation and is more of a workaround than a standard way of doing it.

It also does not offer a way to insert the HTML without adding another level to the DOM tree.

There should be a way to insert HTML from a variable or expression without adding an extra element.

For example something like this:

// this can be coming from an API call
let price= "<del>$11.95</del><ins>$9.99</ins>"  
<div>
  "Price: ", HTML price
  <button> "Add to Cart

Where HTML would be a special function or construct to add the content of the price as HTML.