packages feed

shakespeare 1.0.5 → 1.0.5.1

raw patch · 4 files changed

+26/−8 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Text/Shakespeare.hs view
@@ -410,15 +410,15 @@ type MTime = UTCTime  {-# NOINLINE reloadMapRef #-}-reloadMapRef :: IORef (M.Map FilePath (MTime, Builder))+reloadMapRef :: IORef (M.Map FilePath (MTime, [Content])) reloadMapRef = unsafePerformIO $ newIORef M.empty -lookupReloadMap :: FilePath -> IO (Maybe (MTime, Builder))+lookupReloadMap :: FilePath -> IO (Maybe (MTime, [Content])) lookupReloadMap fp = do   reloads <- readIORef reloadMapRef   return $ M.lookup fp reloads -insertReloadMap :: FilePath -> (MTime, Builder) -> IO Builder+insertReloadMap :: FilePath -> (MTime, [Content]) -> IO [Content] insertReloadMap fp (mt, content) = atomicModifyIORef reloadMapRef   (\reloadMap -> (M.insert fp (mt, content) reloadMap, content)) @@ -453,14 +453,16 @@     mdata <- lookupReloadMap fp     case mdata of       Just (lastMtime, lastContents) ->-        if mtime == lastMtime then return lastContents-          else newContent mtime-      Nothing -> newContent mtime+        if mtime == lastMtime then return $ go' lastContents+          else fmap go' $ newContent mtime+      Nothing -> fmap go' $ newContent mtime   where     newContent mtime = do         str <- readFileUtf8 fp         s <- preFilter (Just fp) settings str-        insertReloadMap fp $ (mtime, mconcat $ map go $ contentFromString settings s)+        insertReloadMap fp $ (mtime, contentFromString settings s)++    go' = mconcat . map go      go :: Content -> Builder     go (ContentRaw s) = fromText $ TS.pack s
shakespeare.cabal view
@@ -1,5 +1,5 @@ name:            shakespeare-version:         1.0.5+version:         1.0.5.1 license:         MIT license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>@@ -21,6 +21,7 @@ cabal-version:   >= 1.8 build-type:      Simple homepage:        http://www.yesodweb.com/book/shakespearean-templates+extra-source-files: test/reload.txt  library     build-depends:   base             >= 4       && < 5
test/ShakespeareBaseTest.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE TemplateHaskell #-} module ShakespeareBaseTest (specs) where  import Test.Hspec@@ -6,6 +7,9 @@ import Text.ParserCombinators.Parsec (parse, ParseError, (<|>)) import Text.Shakespeare.Base (parseVarString, parseUrlString, parseIntString) import Text.Shakespeare (preFilter, defaultShakespeareSettings, ShakespeareSettings(..), PreConvert(..), PreConversion(..))+import Language.Haskell.TH.Syntax (Exp (VarE))+import Data.Text.Lazy.Builder (fromString, toLazyText)+import Data.Text.Lazy (pack)  -- run :: Text.Parsec.Prim.Parsec Text.Parsec.Pos.SourceName () c -> Text.Parsec.Pos.SourceName -> c @@ -36,6 +40,16 @@   it "preFilter ignore comments" $ do     preFilterN preConversionSettings templateCommented       `shouldReturn` "unchanged & '#{var}' @{url} '^{int}'"++  it "reload" $ do+    let helper input = $(do+            shakespeareFileReload defaultShakespeareSettings+                { toBuilder = VarE 'fromString+                , wrap = VarE 'toLazyText+                , unwrap = VarE 'undefined+                } "test/reload.txt") undefined+    helper "here1" `shouldBe` pack "here1\n"+    helper "here2" `shouldBe` pack "here2\n"    where     varString = parseVarString '%'
+ test/reload.txt view
@@ -0,0 +1,1 @@+#{input}