I want to include a svg diagram generated with blaze-svg directly in html generated with blaze-html. Both are based on blaze-markup, so I expected it to be easy.
diagram1 :: Svg
diagram1 = ...
try1 :: Html
try1 = html $
body $ do
h1 "My first diagram"
toHtml diagram1
try2 :: Html
try2 :: html $
body $ do
h1 "My first diagram"
toHtml $ renderSvg diagram1
Both try1 and try2 passes the compiler but neither shows the diagram. What is the right way? Is it a problem with including the svg tag directly?
try2
first generates a string representation of the SVG withrenderSvg
, escapes it (toHtml
) and includes the result into the HTML output. Using it, you should see the source of the SVG instead of the resulting image.try1
should actually work.toHtml
is defined as the identity on theSvg
type, so you could also just usediagram1
directly.Here is a complete example that generates a HTML document with embedded SVG: