stache 0.2.0 → 0.2.1
raw patch · 10 files changed
+41/−22 lines, 10 filesdep ~stache
Dependency ranges changed: stache
Files
- CHANGELOG.md +4/−0
- LICENSE.md +1/−1
- README.md +1/−1
- Text/Mustache.hs +1/−1
- Text/Mustache/Compile.hs +1/−1
- Text/Mustache/Compile/TH.hs +20/−5
- Text/Mustache/Parser.hs +1/−1
- Text/Mustache/Render.hs +1/−1
- Text/Mustache/Type.hs +1/−1
- stache.cabal +10/−10
CHANGELOG.md view
@@ -1,3 +1,7 @@+## Stache 0.2.1++* Made TH parse errors nicer.+ ## Stache 0.2.0 * Breaking change: the `renderMustache` function will throw an exception
LICENSE.md view
@@ -1,4 +1,4 @@-Copyright © 2016 Stack Builders+Copyright © 2016–2017 Stack Builders All rights reserved.
README.md view
@@ -77,6 +77,6 @@ ## License -Copyright © 2016 Stack Builders+Copyright © 2016–2017 Stack Builders Distributed under BSD 3 clause license.
Text/Mustache.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Text.Mustache--- Copyright : © 2016 Stack Builders+-- Copyright : © 2016–2017 Stack Builders -- License : BSD 3 clause -- -- Maintainer : Mark Karpov <markkarpov@openmailbox.org>
Text/Mustache/Compile.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Text.Mustache.Compile--- Copyright : © 2016 Stack Builders+-- Copyright : © 2016–2017 Stack Builders -- License : BSD 3 clause -- -- Maintainer : Mark Karpov <markkarpov@openmailbox.org>
Text/Mustache/Compile/TH.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Text.Mustache.Compile.TH--- Copyright : © 2016 Stack Builders+-- Copyright : © 2016–2017 Stack Builders -- License : BSD 3 clause -- -- Maintainer : Mark Karpov <markkarpov@openmailbox.org>@@ -26,13 +26,13 @@ , mustache ) where +import Control.Exception (Exception(..)) import Control.Monad.Catch (try) import Data.Text.Lazy (Text) import Data.Typeable (cast) import Language.Haskell.TH hiding (Dec) import Language.Haskell.TH.Quote (QuasiQuoter (..)) import Language.Haskell.TH.Syntax (lift)-import Text.Megaparsec hiding (try) import Text.Mustache.Type import qualified Data.Text as T import qualified Data.Text.Lazy as TL@@ -83,7 +83,8 @@ -> Text -- ^ The template to compile -> Q Exp compileMustacheText pname text =- handleEither (C.compileMustacheText pname text)+ (handleEither . either (Left . MustacheParserException) Right)+ (C.compileMustacheText pname text) -- | Compile Mustache using QuasiQuoter. Usage: --@@ -109,11 +110,25 @@ -- | Given an 'Either' result return 'Right' and signal pretty-printed error -- if we have a 'Left'. -handleEither :: Either (ParseError Char Dec) Template -> Q Exp+handleEither :: Either MustacheException Template -> Q Exp handleEither val = case val of- Left err -> fail (parseErrorPretty err)+ Left err -> fail . indentNicely $+#if MIN_VERSION_base(4,8,0)+ displayException err+#else+ show err+#endif Right template -> dataToExpQ (fmap liftText . cast) template+ where+ -- NOTE Since the feature requires GHC 8 anyway, we follow indentation+ -- style of that version of compiler. This makes it look consistent with+ -- other error messages and allows Emacs and similar tools to parse the+ -- errors correctly.+ indentNicely x' =+ case lines x' of+ [] -> ""+ (x:xs) -> unlines (x : fmap (replicate 8 ' ' ++) xs) -- | Lift strict 'T.Text' to 'Q' 'Exp'.
Text/Mustache/Parser.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Text.Mustache.Parser--- Copyright : © 2016 Stack Builders+-- Copyright : © 2016–2017 Stack Builders -- License : BSD 3 clause -- -- Maintainer : Mark Karpov <markkarpov@openmailbox.org>
Text/Mustache/Render.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Text.Mustache.Render--- Copyright : © 2016 Stack Builders+-- Copyright : © 2016–2017 Stack Builders -- License : BSD 3 clause -- -- Maintainer : Mark Karpov <markkarpov@openmailbox.org>
Text/Mustache/Type.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Text.Mustache.Type--- Copyright : © 2016 Stack Buliders+-- Copyright : © 2016–2017 Stack Buliders -- License : BSD 3 clause -- -- Maintainer : Mark Karpov <markkarpov@openmailbox.org>
stache.cabal view
@@ -1,7 +1,7 @@ -- -- Cabal configuration for ‘stache’ package. ----- Copyright © 2016 Stack Builders+-- Copyright © 2016–2017 Stack Builders -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are@@ -31,7 +31,7 @@ -- POSSIBILITY OF SUCH DAMAGE. name: stache-version: 0.2.0+version: 0.2.1 cabal-version: >= 1.10 license: BSD3 license-file: LICENSE.md@@ -59,7 +59,7 @@ default: False library- build-depends: aeson >= 0.11 && < 1.1+ build-depends: aeson >= 0.11 && < 1.2 , base >= 4.7 && < 5.0 , bytestring >= 0.10 && < 0.11 , containers >= 0.5 && < 0.6@@ -72,7 +72,7 @@ , template-haskell >= 2.10 && < 2.12 , text >= 1.2 && < 1.3 , unordered-containers >= 0.2.5 && < 0.3- , vector >= 0.11 && < 0.12+ , vector >= 0.11 && < 0.13 if !impl(ghc >= 8.0) build-depends: semigroups == 0.18.* exposed-modules: Text.Mustache@@ -91,13 +91,13 @@ main-is: Spec.hs hs-source-dirs: tests type: exitcode-stdio-1.0- build-depends: aeson >= 0.11 && < 1.1+ build-depends: aeson >= 0.11 && < 1.2 , base >= 4.7 && < 5.0 , containers >= 0.5 && < 0.6 , hspec >= 2.0 && < 3.0 , hspec-megaparsec >= 0.2 && < 0.4 , megaparsec >= 5.0 && < 6.0- , stache >= 0.2.0+ , stache >= 0.2.1 , text >= 1.2 && < 1.3 other-modules: Text.Mustache.Compile.THSpec , Text.Mustache.ParserSpec@@ -115,14 +115,14 @@ main-is: Spec.hs hs-source-dirs: mustache-spec type: exitcode-stdio-1.0- build-depends: aeson >= 0.11 && < 1.1+ build-depends: aeson >= 0.11 && < 1.2 , base >= 4.7 && < 5.0 , bytestring >= 0.10 && < 0.11 , containers >= 0.5 && < 0.6 , file-embed , hspec >= 2.0 && < 3.0 , megaparsec >= 5.0 && < 6.0- , stache >= 0.2.0+ , stache >= 0.2.1 , text >= 1.2 && < 1.3 , yaml >= 0.8 && < 0.9 if flag(dev)@@ -135,12 +135,12 @@ main-is: Main.hs hs-source-dirs: bench type: exitcode-stdio-1.0- build-depends: aeson >= 0.11 && < 1.1+ build-depends: aeson >= 0.11 && < 1.2 , base >= 4.7 && < 5.0 , criterion >= 0.6.2.1 && < 1.2 , deepseq >= 1.4 && < 1.5 , megaparsec >= 5.0 && < 6.0- , stache >= 0.2.0+ , stache >= 0.2.1 , text >= 1.2 && < 1.3 if flag(dev) ghc-options: -O2 -Wall -Werror