packages feed

shakespeare 2.0.18 → 2.0.19

raw patch · 10 files changed

+58/−31 lines, 10 files

Files

ChangeLog.md view
@@ -1,3 +1,7 @@++### 2.0.19+* Change of the default behaviour of `*File` functions, they now will add their templates' source file to ghc-dependencies, thus recompiling on templates' changes.+ ### 2.0.18  * ToJavascript instance for String, Strict and Lazy Text [#227](https://github.com/yesodweb/shakespeare/pull/227)
Text/Cassius.hs view
@@ -55,7 +55,7 @@  cassiusFile :: FilePath -> Q Exp cassiusFile fp = do-    contents <- fmap TL.unpack $ qRunIO $ readUtf8File fp+    contents <- readFileRecompileQ fp     quoteExp cassius contents  cassiusFileDebug, cassiusFileReload :: FilePath -> Q Exp
Text/Hamlet.hs view
@@ -413,7 +413,7 @@  hamletFileWithSettings :: Q HamletRules -> HamletSettings -> FilePath -> Q Exp hamletFileWithSettings qhr set fp = do-    contents <- fmap TL.unpack $ qRunIO $ readUtf8File fp+    contents <- readFileRecompileQ fp     hamletFromString qhr set contents  -- | Like 'hamlet', but reads an external file at compile time.@@ -550,14 +550,6 @@             c VTMixin = [|\r -> EMixin $ \c -> r c|]             c VTMsg = [|EMsg|] --- move to Shakespeare.Base?-readFileUtf8 :: FilePath -> IO String-readFileUtf8 fp = fmap TL.unpack $ readUtf8File fp---- move to Shakespeare.Base?-readFileQ :: FilePath -> Q String-readFileQ fp = qRunIO $ readFileUtf8 fp- {-# NOINLINE reloadMapRef #-} reloadMapRef :: IORef (M.Map FilePath (MTime, [Content])) reloadMapRef = unsafePerformIO $ newIORef M.empty@@ -599,7 +591,7 @@       Nothing -> fmap go' $ newContent mtime   where     newContent mtime = do-        s <- readFileUtf8 fp+        s <- readUtf8FileString fp         insertReloadMap fp (mtime, contentFromString settings s)      go' = mconcat . map (runtimeContentToHtml cd render (error "I18n embed IMPOSSIBLE") handleMsgEx)@@ -620,7 +612,7 @@       Nothing -> fmap go' $ newContent mtime   where     newContent mtime = do-        s <- readFileUtf8 fp+        s <- readUtf8FileString fp         insertReloadMap fp (mtime, contentFromString settings s)      go' = mconcat . map (runtimeContentToHtml cd render i18nRender handleMsg)
Text/Internal/Css.hs view
@@ -165,7 +165,7 @@              -> FilePath              -> Q Exp cssFileDebug toi2b parseBlocks' parseBlocks fp = do-    s <- fmap TL.unpack $ qRunIO $ readUtf8File fp+    s <- readFileQ fp     let vs = cssUsedIdentifiers toi2b parseBlocks s     c <- mapM vtToExp vs     cr <- [|cssRuntime toi2b|]@@ -252,7 +252,7 @@            -> (url -> [(Text, Text)] -> Text)            -> Css cssRuntime toi2b parseBlocks fp cd render' = unsafePerformIO $ do-    s' <- fmap TL.unpack $ qRunIO $ readUtf8File fp+    s' <- readUtf8FileString fp     let s = if toi2b then i2b s' else s'     let a = either (error . show) id $ parse parseBlocks s s     return $ CssWhitespace $ goTop [] a
Text/Lucius.hs view
@@ -222,7 +222,7 @@  luciusFile :: FilePath -> Q Exp luciusFile fp = do-    contents <- fmap TL.unpack $ qRunIO $ readUtf8File fp+    contents <- readFileRecompileQ fp     luciusFromString contents  luciusFileDebug, luciusFileReload :: FilePath -> Q Exp
Text/MkSizeType.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE TemplateHaskell #-}  -- | Internal functions to generate CSS size wrapper types. module Text.MkSizeType (mkSizeType) where
Text/Shakespeare.hs view
@@ -47,7 +47,6 @@ #endif import System.IO.Unsafe (unsafePerformIO) import qualified Data.Text as TS-import qualified Data.Text.Lazy as TL import Text.Shakespeare.Base  import System.Directory (getModificationTime)@@ -68,14 +67,6 @@ parse ::  GenParser tok [a1] a -> SourceName -> [tok] -> Either ParseError a parse p = runParser p [] --- move to Shakespeare.Base?-readFileQ :: FilePath -> Q String-readFileQ fp = qRunIO $ readFileUtf8 fp---- move to Shakespeare.Base?-readFileUtf8 :: FilePath -> IO String-readFileUtf8 fp = fmap TL.unpack $ readUtf8File fp- -- | Coffeescript, TypeScript, and other languages compiles down to Javascript. -- Previously we waited until the very end, at the rendering stage to perform this compilation. -- Lets call is a post-conversion@@ -384,7 +375,7 @@     contentsToShakespeare r $ contentFromString r s  shakespeareFile :: ShakespeareSettings -> FilePath -> Q Exp-shakespeareFile r fp = readFileQ fp >>= shakespeareFromString r+shakespeareFile r fp = readFileRecompileQ fp >>= shakespeareFromString r  data VarType = VTPlain | VTUrl | VTUrlParam | VTMixin     deriving (Show, Eq, Ord, Enum, Bounded, Typeable, Data, Generic)@@ -460,7 +451,7 @@       Nothing -> fmap go' $ newContent mtime   where     newContent mtime = do-        str <- readFileUtf8 fp+        str <- readUtf8FileString fp         s <- preFilter (Just fp) settings str         insertReloadMap fp (mtime, contentFromString settings s) 
Text/Shakespeare/Base.hs view
@@ -21,6 +21,9 @@     , derefToExp     , flattenDeref     , readUtf8File+    , readUtf8FileString+    , readFileQ+    , readFileRecompileQ     ) where  import Language.Haskell.TH.Syntax@@ -281,6 +284,12 @@         deref <- derefCurlyBrackets         return $ Right deref) <|> return (Left "_") +-- | Read file's content as `String`, converting newlines+--+-- @since 2.0.19+readUtf8FileString :: FilePath -> IO String+readUtf8FileString fp = fmap TL.unpack $ readUtf8File fp+ readUtf8File :: FilePath -> IO TL.Text readUtf8File fp = do     h <- SIO.openFile fp SIO.ReadMode@@ -292,3 +301,16 @@ #else       ret #endif++-- | Embed file's content, converting newlines+--+-- @since 2.0.19+readFileQ :: FilePath -> Q String+readFileQ fp = qRunIO (readUtf8FileString fp)++-- | Embed file's content, converting newlines+-- and track file via ghc dependencies, recompiling on changes+--+-- @since 2.0.19+readFileRecompileQ :: FilePath -> Q String+readFileRecompileQ fp = addDependentFile fp >> readFileQ fp
Text/Shakespeare/Text.hs view
@@ -2,6 +2,27 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE FlexibleInstances #-} {-# OPTIONS_GHC -fno-warn-missing-fields #-}+-- | A Shakespearean module for general text processing, introducing type-safe,+-- compile-time variable interpolation.+--+-- Text templates use the same parser as for other shakespearean templates+-- which enables variable interpolation using @#{..}@.  The parser also+-- recognize the @@{..}@ and @^{..}@ syntax.+--+-- If it is necessary that your template produces the output containing one of+-- the interpolation syntax you can escape the sequence using a backslash:+--+-- > λ> :set -XQuasiQuotes+-- > λ> let bar = 23 :: Int in [st|#{bar}|] :: Text+--+-- produces "23", but+--+-- > λ> let bar = 23 :: Int in [st|#\{bar}|] :: Text+--+-- returns "#{bar}".  The escaping backslash is removed from the output.+--+-- Further reading:+-- Shakespearean templates: <https://www.yesodweb.com/book/shakespearean-templates> module Text.Shakespeare.Text     ( TextUrl     , ToText (..)
shakespeare.cabal view
@@ -1,5 +1,5 @@ name:            shakespeare-version:         2.0.18+version:         2.0.19 license:         MIT license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>@@ -77,8 +77,6 @@     if flag(test_export)       cpp-options: -DTEST_EXPORT -    extensions: TemplateHaskell-     if os(windows)       CPP-Options: "-DWINDOWS" @@ -139,8 +137,6 @@                  , blaze-markup                  , blaze-html                  , exceptions--    extensions: TemplateHaskell   source-repository head