Created
June 14, 2010 01:49
-
-
Save duairc/437187 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
module Splices where | |
import Data.ByteString.Char8(ByteString) | |
import qualified Data.ByteString.Char8 as B | |
import Data.Maybe | |
import Snap.Types | |
import Text.Templating.Heist | |
import Text.XML.Expat.Tree hiding (Node) | |
splices :: [(ByteString, Splice Snap)] | |
splices = [ ("menu", menuSplice) | |
, ("item", itemSplice) ] | |
menuSplice :: Splice Snap | |
menuSplice = do | |
input <- getParamNode | |
return [mkElement "ul" [] $ getChildren input] | |
itemSplice :: Splice Snap | |
itemSplice = do | |
input <- getParamNode | |
let href = fromJust $ getAttribute "href" input | |
text = fromJust $ getAttribute "text" input | |
a = mkElement "a" [ ("href", href) | |
, ("title", text) ] [mkText $ text] | |
return [mkElement "li" [] $ a:getChildren input] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment