mustache 2.3.0 → 2.3.1
raw patch · 5 files changed
+56/−38 lines, 5 filesdep ~template-haskelldep ~text
Dependency ranges changed: template-haskell, text
Files
- mustache.cabal +41/−34
- src/Text/Mustache/Compile.hs +3/−3
- src/Text/Mustache/Internal/Types.hs +4/−0
- src/Text/Mustache/Render.hs +3/−0
- test/unit/Spec.hs +5/−1
mustache.cabal view
@@ -1,9 +1,13 @@--- This file has been generated from package.yaml by hpack version 0.17.1.+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.31.2. -- -- see: https://github.com/sol/hpack+--+-- hash: 8ffde004ee64f5b057ed66f76bbc72cbb71cdc81dcebe9e822563fdb11a8b338 name: mustache-version: 2.3.0+version: 2.3.1 synopsis: A mustache template parser library. description: Allows parsing and rendering template files with mustache markup. See the mustache <http://mustache.github.io/mustache.5.html language reference>.@@ -16,20 +20,17 @@ bug-reports: https://github.com/JustusAdam/mustache/issues author: Justus Adam maintainer: dev@justus.science-copyright: (c) 2015,- 2016 Justus Adam+copyright: (c) 2015 - 2019 Justus Adam license: BSD3 license-file: LICENSE tested-with: GHC>=7.8 && <=7.10.2 build-type: Simple-cabal-version: >= 1.10- extra-source-files:- CHANGELOG.md README.md- test/unit/examples/partials/test-partial.txt.mustache+ CHANGELOG.md test/unit/examples/test-template-partials.txt.mustache test/unit/examples/test-template.txt.mustache+ test/unit/examples/partials/test-partial.txt.mustache source-repository head type: git@@ -42,21 +43,21 @@ other-extensions: NamedFieldPuns OverloadedStrings LambdaCase TupleSections TemplateHaskell QuasiQuotes ghc-options: -Wall build-depends:- base >=4.7 && <5- , text- , aeson+ aeson+ , base >=4.7 && <5 , bytestring+ , containers+ , directory+ , either , filepath- , parsec , mtl >=2.2.1- , either- , unordered-containers- , vector- , directory+ , parsec , scientific- , containers , template-haskell+ , text , th-lift+ , unordered-containers+ , vector exposed-modules: Text.Mustache Text.Mustache.Types@@ -71,58 +72,64 @@ executable haskell-mustache main-is: Main.hs+ other-modules:+ Paths_mustache hs-source-dirs: app ghc-options: -threaded -Wall build-depends:- base >=4.7 && <5- , text- , aeson+ aeson+ , base >=4.7 && <5 , bytestring+ , cmdargs , filepath , mustache+ , text , yaml- , cmdargs default-language: Haskell2010 test-suite language-specifications type: exitcode-stdio-1.0 main-is: Language.hs+ other-modules:+ Paths_mustache hs-source-dirs: test/integration build-depends:- base >=4.7 && <5- , text- , aeson+ aeson+ , base >=4.7 && <5+ , base-unicode-symbols , bytestring , filepath , hspec+ , lens , mustache+ , tar+ , text , unordered-containers- , yaml- , base-unicode-symbols , wreq+ , yaml , zlib- , tar- , lens default-language: Haskell2010 test-suite unit-tests type: exitcode-stdio-1.0 main-is: Spec.hs+ other-modules:+ Paths_mustache hs-source-dirs: test/unit build-depends:- base >=4.7 && <5- , text- , aeson+ aeson+ , base >=4.7 && <5 , bytestring+ , directory , filepath , hspec , mustache- , unordered-containers- , yaml , process , temporary- , directory+ , text+ , unordered-containers+ , yaml default-language: Haskell2010
src/Text/Mustache/Compile.hs view
@@ -92,7 +92,7 @@ (getPartials mSTree) --- | Flatten a list of Templates into a single 'TemplateChache'+-- | Flatten a list of Templates into a single 'TemplateCache' cacheFromList :: [Template] -> TemplateCache cacheFromList = flattenPartials . fromList . fmap (name &&& id) @@ -185,10 +185,10 @@ -- Compile a mustache 'Template' at compile time. Usage: -- -- > {-# LANGUAGE TemplateHaskell #-}--- > import Text.Mustache.Compile (embedTemplate)+-- > import Text.Mustache.Compile (embedSingleTemplate) -- > -- > foo :: Template--- > foo = $(embedTemplate "dir/file.mustache")+-- > foo = $(embedSingleTemplate "dir/file.mustache") -- -- Partials are not supported in embedSingleTemplate
src/Text/Mustache/Internal/Types.hs view
@@ -1,5 +1,6 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MultiParamTypeClasses #-}@@ -347,8 +348,11 @@ instance Lift TemplateCache where lift m = [| HM.fromList $(lift $ HM.toList m) |] +--Data.Text 1.2.4.0 introduces its own Lift Text instance+#if !MIN_VERSION_text(1,2,4) instance Lift Text where lift = lift . unpack+#endif deriveLift ''DataIdentifier deriveLift ''Node
src/Text/Mustache/Render.hs view
@@ -217,6 +217,9 @@ toString :: Value -> SubM Text toString (String t) = return t toString (Number n) = return $ either (pack . show) (pack . show) (floatingOrInteger n :: Either Double Integer)+toString (Lambda l) = do+ ((), res) <- catchSubstitute $ substituteAST =<< l []+ return res toString e = do tellError $ DirectlyRenderedValue e return $ pack $ show e
test/unit/Spec.hs view
@@ -191,7 +191,6 @@ (object ["lambda" ~> (overText T.toUpper)]) `shouldBe` "T" - it "substitutes a lambda by applying lambda to the nested substitution results" $ substitute (toTemplate [Section (NamedData ["lambda"]) [TextBlock "t", Variable escaped (NamedData ["inner"])]])@@ -200,6 +199,11 @@ ]) `shouldBe` "TVAR" + it "substitutes a lambda used directly as if applied to empty block" $+ substitute+ (toTemplate [Variable escaped (NamedData ["lambda"])])+ (object ["lambda" ~> (Lambda $ \[] -> return [TextBlock "T"])])+ `shouldBe` "T" it "substitutes a nested section" $ substitute