diff --git a/src/Text/Templating/Heist/Types.hs b/src/Text/Templating/Heist/Types.hs index 2737980..941dcbb 100644 --- a/src/Text/Templating/Heist/Types.hs +++ b/src/Text/Templating/Heist/Types.hs @@ -9,7 +9,7 @@ {-| This module contains the core Heist data types. TemplateMonad intentionally -does not expose any of it's functionality via MonadState or MonadReader +does not expose any of its functionality via MonadState or MonadReader functions. We define passthrough instances for the most common types of monads. These instances allow the user to use TemplateMonad in a monad stack without needing calls to `lift`. diff --git a/test/suite/Text/Templating/Heist/Tests.hs b/test/suite/Text/Templating/Heist/Tests.hs index f52dd22..8908643 100644 --- a/test/suite/Text/Templating/Heist/Tests.hs +++ b/test/suite/Text/Templating/Heist/Tests.hs @@ -31,6 +31,7 @@ import Text.Templating.Heist.Internal import Text.Templating.Heist.Types import Text.Templating.Heist.Splices.Apply import Text.Templating.Heist.Splices.Ignore +import Text.Templating.Heist.Splices.Markdown import Text.XML.Expat.Cursor import Text.XML.Expat.Format import qualified Text.XML.Expat.Tree as X @@ -51,6 +52,7 @@ tests = [ testProperty "heist/simpleBind" simpleBindTest , testCase "heist/attributeSubstitution" attrSubstTest , testCase "heist/bindAttribute" bindAttrTest , testCase "heist/markdown" markdownTest + , testCase "heist/markdownText" markdownTextTest , testCase "heist/apply" applyTest , testCase "heist/ignore" ignoreTest ] @@ -203,12 +205,18 @@ bindAttrTest = do ------------------------------------------------------------------------------ +htmlExpected :: ByteString +htmlExpected = "

This is a test.

" + + +------------------------------------------------------------------------------ +-- | Markdown test on a file markdownTest :: H.Assertion markdownTest = do ets <- loadT "templates" let ts = either (error "Error loading templates") id ets - check ts "

This is a test.

" + check ts htmlExpected where check ts str = do @@ -217,12 +225,23 @@ markdownTest = do H.assertEqual ("Should match " ++ (show str)) str (fromJust result) +------------------------------------------------------------------------------ +-- | Markdown test on supplied text +markdownTextTest :: H.Assertion +markdownTextTest = do + result <- evalTemplateMonad markdownSplice + (X.Text "This *is* a test.") emptyTemplateState + H.assertEqual "Markdown text" htmlExpected + (B.filter (/= '\n') $ formatList' result) + + ------------------------------------------------------------------------------ applyTest :: H.Assertion applyTest = do let es = emptyTemplateState :: TemplateState IO res <- evalTemplateMonad applyImpl (X.Element "apply" [("template", "nonexistant")] []) es + H.assertEqual "apply nothing" [] res