How do I embed long text documents into a SPA?

I used a legal website to draft a Terms and Conditions page, which they provided me in the form of HTML with basic tags like


, <etc.>. It’s about 14kb.

I’d like to display this from within an Elm single-page application. I found HTML to Elm but it only translates about the first third of of the source and ignores the rest. Also, the text has quotes (") and they’re not properly escaped in the elm code.

Is there a better solution?

Maybe there’s a bug in your HTML so it skips the remainder?

A WebComponent might solve your issues. The legal document HTML would simply be set as its innerHTML. From the Elm point of view you would just do Html.node "x-legal-document" [] [].

Let me know if this explanation was too shortcutty; I skipped over details of the WebComponent but can fill those in.


Really depends on the use-case etc. and it would obviously be better to be able to translate all this HTML into Elm as you have tried. But if you’re looking for a ‘quick’ solution, you can use elm-markdown with sanitization turned off, in which case it basically just displays the HTML.

1 Like

Maybe this can be simple html document and show it in iframe ?

You can use the srcdoc attribute on iframes for that (canIuse).

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.