Search code examples
htmlhaskellyesodhamlet

Double Quotes in Single Quotes


I need to put json in an html attribute like so:

<video id="video1" 
class="video-js vjs-default-skin" 
width="640" height="480" 
data-setup='{"controls" : true, "autoplay" : false, "preload" : "auto"}'>

Hamlet does not understand html single quote strings, it creates the error message:

unexpected ":" expecting ">"

What is the recommended practice for adding literal json to html attributes in a string?


Solution

  • Escape the quotes in html using &quot;

    <video id="video1" 
    class="video-js vjs-default-skin" 
    width="640" height="480" 
    data-setup='{ &quot;controls&quot;:true,&quot;autoplay&quot;:false,&quot;preload&quot;: &quot;auto&quot;}'>