Search code examples
elm

Insert raw HTML into Elm component


How do I insert text - that I know to be 'safe' - directly into an Elm page.

i.e. what is text' in the following.

let str = "<h1>Hello World</h1>"
in div [] [ text' str ]

In practise I could get any valid HTML, so I don't want to build a parser, and I'd rather avoid a port as playing around wit the DOM can break the virtual dom diffing


Solution

  • There are a few solutions discussed in this post. Seems the poster had success with using Markdown.toHtml.