user4828533
user4828533

Reputation:

Haskell Blaze HTML

been writing an application that consumes JSON data and then displays it using Happstack.

   helloBlaze :: ServerPart Response
   helloBlaze =
   ok $ toResponse $
   appTemplate "Hello, Blaze!"
            [H.meta ! A.name "keywords"
                    ! A.content "happstack, blaze, html"
            ]
            (do H.toHtml $ makeList $ getResponse)

   makeList xs = "<ul>" ++ (Items xs) ++ "</ul>"

   Items [] = ""
   Items (x:xs) = "<li>" ++ x ++ "</li>" ++ (Items xs)

The problem is when I run Happstack the response generated is the results but with html tags still showing. Any suggestions would be much appreciated.

Upvotes: 0

Views: 203

Answers (1)

MathematicalOrchid
MathematicalOrchid

Reputation: 62818

I don't know Blaze all that well, but isn't the correct way to do this something more like

makeList xs = ul (mapM_ li xs)

That's how this works, isn't it?

(Also, don't use Items as a function name. It needs to start with a lowercase letter.)

Upvotes: 1

Related Questions