module Heist.Splices.BindStrict where
import Data.Text (Text)
import qualified Data.Text as T
import qualified Text.XmlHtml as X
import Heist.Common
import Heist.Interpreted.Internal
import Heist.Splices.Apply
import Heist.Splices.Bind
import Heist.Internal.Types.HeistState
bindStrictTag :: Text
bindStrictTag = "bindStrict"
bindStrictImpl :: Monad n => Splice n
bindStrictImpl = do
node <- getParamNode
cs <- runChildren
let err = "must supply \"" ++ T.unpack bindAttr ++
"\" attribute in <" ++ T.unpack (X.elementTag node) ++ ">"
maybe (return () `orError` err) (add cs)
(X.getAttribute bindAttr node)
return []
where
add cs nm = modifyHS $ bindSplice nm $ do
caller <- getParamNode
ctx <- getContext
rawApply "bindstrict-content" cs Nothing ctx (X.childNodes caller)