heist 0.10.2 → 0.10.2.1
raw patch · 8 files changed
+14/−33 lines, 8 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- heist.cabal +1/−1
- src/Heist/Common.hs +1/−7
- src/Heist/Compiled/Internal.hs +4/−4
- src/Heist/Interpreted/Internal.hs +2/−14
- src/Heist/Types.hs +0/−1
- test/suite/Heist/Interpreted/Tests.hs +3/−3
- test/suite/Heist/Tests.hs +2/−2
- test/templates/attrs.tpl +1/−1
heist.cabal view
@@ -1,5 +1,5 @@ name: heist-version: 0.10.2+version: 0.10.2.1 synopsis: An Haskell template system supporting both HTML5 and XML. description: Heist is a powerful template system that supports both HTML5 and XML.
src/Heist/Common.hs view
@@ -81,17 +81,11 @@ go !subDL = (gobbleText >>= go . append subDL) <|> (AP.endOfInput *> finish subDL) <|> (do- res <- escSequence- dl' <- finish subDL- loop $! append dl' res)- <|> (do idp <- identParser dl' <- finish subDL loop $! append dl' idp) - gobbleText = AP.takeWhile1 (AP.notInClass "\\$")-- escSequence = AP.char '\\' *> (Escaped <$> AP.anyChar)+ gobbleText = AP.takeWhile1 (AP.notInClass "$") identParser = AP.char '$' *> (ident <|> return (Literal "$")) ident = (AP.char '{' *> (Ident <$> AP.takeWhile (/='}')) <* AP.string "}")
src/Heist/Compiled/Internal.hs view
@@ -335,8 +335,7 @@ (AP.Fail _ _ _) -> [] (AP.Partial _ ) -> [] cvt (Literal x) = x- cvt (Escaped c) = T.singleton c- cvt (Ident _) = error "parseAttrs: impossible case"+ cvt (Ident i) = T.concat ["${", i, "}"] ------------------------------------------------------------------------------ -- | Checks whether a node's subtree is static and can be rendered up front at@@ -380,7 +379,6 @@ where cvt (Literal x) = return $ yieldPureText x- cvt (Escaped c) = return $ yieldPureText $ T.singleton c cvt (Ident x) = localParamNode (const $ X.Element x [] []) $ getAttributeSplice x @@ -464,7 +462,9 @@ ------------------------------------------------------------------------------ getAttributeSplice :: Text -> HeistT n IO (DList (Chunk n)) getAttributeSplice name =- lookupSplice name >>= fromMaybe (return DL.empty)+ lookupSplice name >>= fromMaybe+ (return $ DL.singleton $ Pure $ T.encodeUtf8 $+ T.concat ["${", name, "}"]) {-# INLINE getAttributeSplice #-}
src/Heist/Interpreted/Internal.hs view
@@ -236,20 +236,10 @@ return $ T.concat chunks where cvt (Literal x) = return x- cvt (Escaped c) = renderEscaped c cvt (Ident x) = localParamNode (const $ X.Element x [] []) $ getAttributeSplice x - renderEscaped c = do- hs <- getHS- if _preprocessingMode hs- -- Load time splices can't be descructive, therefore we need to- -- output the slashes so we don't change anything before later- -- splice processing.- then return $ T.snoc "\\" c- else return $ T.singleton c - ------------------------------------------------------------------------------ -- | Gets the attribute value. If the splice's result list contains non-text -- nodes, this will translate them into text nodes with nodeText and@@ -275,10 +265,8 @@ getAttributeSplice :: Monad n => Text -> HeistT n n Text getAttributeSplice name = do hs <- getHS- let noSplice = if _preprocessingMode hs- then return $ T.concat ["${", name, "}"]- else return ""- let s = lookupSplice name hs+ let noSplice = return $ T.concat ["${", name, "}"]+ s = lookupSplice name hs maybe noSplice (liftM (T.concat . map X.nodeText)) s ------------------------------------------------------------------------------
src/Heist/Types.hs view
@@ -477,7 +477,6 @@ -- attoparsec doesn't support parsers running in another monad. data AttAST = Literal Text | Ident Text- | Escaped Char deriving (Show)
test/suite/Heist/Interpreted/Tests.hs view
@@ -202,13 +202,13 @@ out1 = B.unlines ["<mytag flag>Empty attribute</mytag>"- ,"<mytag flag='abc${foo}'>No ident capture</mytag>"+ ,"<mytag flag='abc${bar}'>No ident capture</mytag>" ,"<div id='pre_meaning_of_everything_post'></div>" ] out2 = B.unlines ["<mytag flag>Empty attribute</mytag>"- ,"<mytag flag='abc${foo}'>No ident capture</mytag>"- ,"<div id='pre__post'></div>"+ ,"<mytag flag='abc${bar}'>No ident capture</mytag>"+ ,"<div id='pre_${foo}_post'></div>" ]
test/suite/Heist/Tests.hs view
@@ -191,6 +191,6 @@ iOut <- iRender hs "backslash" H.assertEqual "interpreted failure" iExpected iOut where- cExpected = "<foo regex='d+\\d'></foo> "- iExpected = "<foo regex='d+\\d'></foo>\n"+ cExpected = "<foo regex='abc\\d+\\\\e'></foo> "+ iExpected = "<foo regex='abc\\d+\\\\e'></foo>\n"
test/templates/attrs.tpl view
@@ -1,3 +1,3 @@ <mytag flag="">Empty attribute</mytag>-<mytag flag="abc\${foo}">No ident capture</mytag>+<mytag flag="abc${bar}">No ident capture</mytag> <div id="pre_${foo}_post"/>