Reputation: 543
I want to integrate Snap's templating and Blaze HTML builder by building some HTML and binding it to a tag for use in a Heist template. Here is what I have attempted.
numbers :: Int -> Splice AppHandler
numbers n = return $ [TextNode $ T.concat.toChunks.renderHtml $ do
p "A list of natural numbers"
ul $ forM_ [1 .. n] (li .toHtml)]
This does not work as intended since snap renders the HTML string directly to the generated page. How do I get snap to render blaze generated HTML?
Upvotes: 2
Views: 449
Reputation: 1555
If you want to stick with a Heist splice, the function renderHtmlNodes
from the Text.Blaze.Renderer.XmlHtml
module in the xmlhtml package should help a lot in this case.
I don't fully understand your example, but this is how I would modify it to incorporate my suggestion:
numbers :: Int -> Splice AppHandler
numbers n = return $ renderHtmlNodes $ do
p "A list of natural numbers"
ul $ forM_ [1 .. n] (li .toHtml)
Upvotes: 3