1 module Text.Templating.Heist.Splices.Bind where 2 3 ------------------------------------------------------------------------------ 4 import Data.Text (Text) 5 import qualified Text.XmlHtml as X 6 7 ------------------------------------------------------------------------------ 8 import Text.Templating.Heist.Internal 9 import Text.Templating.Heist.Splices.Apply 10 import Text.Templating.Heist.Types 11 12 -- | Default name for the bind splice. 13 bindTag :: Text 14 bindTag = "bind" 15 16 17 ------------------------------------------------------------------------------ 18 -- | Default attribute name for the bind tag. 19 bindAttr :: Text 20 bindAttr = "tag" 21 22 23 ------------------------------------------------------------------------------ 24 -- | Implementation of the bind splice. 25 bindImpl :: Monad m => Splice m 26 bindImpl = do 27 node <- getParamNode 28 maybe (return ()) 29 (add node) 30 (X.getAttribute bindAttr node) 31 return [] 32 33 where 34 add node nm = modifyTS $ bindSplice nm $ do 35 caller <- getParamNode 36 ctx <- getContext 37 rawApply (X.childNodes node) ctx (X.childNodes caller) 38 39