stache 2.1.0 → 2.1.1
raw patch · 10 files changed
+57/−36 lines, 10 filesdep ~aesondep ~basedep ~template-haskell
Dependency ranges changed: aeson, base, template-haskell
Files
- CHANGELOG.md +7/−0
- README.md +6/−6
- Text/Mustache/Parser.hs +5/−1
- Text/Mustache/Render.hs +7/−4
- Text/Mustache/Type.hs +0/−5
- stache.cabal +11/−12
- tests/Text/Mustache/Compile/THSpec.hs +3/−6
- tests/Text/Mustache/ParserSpec.hs +5/−1
- tests/Text/Mustache/RenderSpec.hs +8/−0
- tests/Text/Mustache/TypeSpec.hs +5/−1
CHANGELOG.md view
@@ -1,3 +1,10 @@+## Stache 2.1.1++* Fixed the bug related to incorrect indentation with nested partials.+ [Issue 44](https://github.com/stackbuilders/stache/issues/44).++* Dropped support for GHC 8.2 and older.+ ## Stache 2.1.0 * Dropped support for GHC 8.0 and older.
README.md view
@@ -7,11 +7,11 @@ [](https://travis-ci.org/stackbuilders/stache) This is a Haskell implementation of Mustache templates. The implementation-conforms to the version 1.1.3 of the-official [Mustache specification](https://github.com/mustache/spec). It is-extremely simple and straightforward to use with minimal but complete-API—three functions to compile templates (from directory, from file, and-from lazy text) and one to render them.+conforms to the version 1.1.3 of the official [Mustache+specification](https://github.com/mustache/spec). It is extremely simple and+straightforward to use with minimal but complete API—three functions to+compile templates (from directory, from file, and from lazy text) and one to+render them. The implementation uses the Megaparsec parsing library to parse the templates which results in superior quality of error messages.@@ -79,7 +79,7 @@ Issues, bugs, and questions may be reported in [the GitHub issue tracker for this project](https://github.com/stackbuilders/stache/issues). -Pull requests are also welcome and will be reviewed quickly.+Pull requests are also welcome. ## License
Text/Mustache/Parser.hs view
@@ -11,6 +11,7 @@ -- import the module, because "Text.Mustache" re-exports everything you may -- need, import that module instead. +{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} module Text.Mustache.Parser@@ -21,7 +22,6 @@ import Control.Monad.State.Strict import Data.Char (isSpace, isAlphaNum) import Data.Maybe (catMaybes)-import Data.Semigroup ((<>)) import Data.Text (Text) import Data.Void import Text.Megaparsec@@ -29,6 +29,10 @@ import Text.Mustache.Type import qualified Data.Text as T import qualified Text.Megaparsec.Char.Lexer as L++#if !MIN_VERSION_base(4,13,0)+import Data.Semigroup ((<>))+#endif ---------------------------------------------------------------------------- -- Parser
Text/Mustache/Render.hs view
@@ -11,6 +11,7 @@ -- import the module, because "Text.Mustache" re-exports everything you may -- need, import that module instead. +{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} module Text.Mustache.Render@@ -24,20 +25,22 @@ import Data.Foldable (asum) import Data.List (tails) import Data.List.NonEmpty (NonEmpty (..))-import Data.Semigroup ((<>)) import Data.Text (Text)-import Text.Megaparsec.Pos (Pos, unPos)+import Text.Megaparsec.Pos (Pos, mkPos, unPos) import Text.Mustache.Type import qualified Data.HashMap.Strict as H import qualified Data.List.NonEmpty as NE import qualified Data.Map as M-import qualified Data.Semigroup as S import qualified Data.Text as T import qualified Data.Text.Lazy as TL import qualified Data.Text.Lazy.Builder as B import qualified Data.Text.Lazy.Encoding as TL import qualified Data.Vector as V +#if !MIN_VERSION_base(4,13,0)+import Data.Semigroup ((<>))+#endif+ ---------------------------------------------------------------------------- -- The rendering monad @@ -250,7 +253,7 @@ addIndents Nothing Nothing = Nothing addIndents Nothing (Just x) = Just x addIndents (Just x) Nothing = Just x-addIndents (Just x) (Just y) = Just (x S.<> y)+addIndents (Just x) (Just y) = Just (mkPos $ unPos x + unPos y - 1) {-# INLINE addIndents #-} -- | Build indentation of specified length by repeating the space character.
Text/Mustache/Type.hs view
@@ -11,7 +11,6 @@ -- because "Text.Mustache" re-exports everything you may need, import that -- module instead. -{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}@@ -42,10 +41,6 @@ import qualified Data.Map as M import qualified Data.Text as T import qualified Language.Haskell.TH.Syntax as TH--#if !MIN_VERSION_base(4,11,0)-import Data.Semigroup-#endif -- | Mustache template as name of “top-level” template and a collection of -- all available templates (partials).
stache.cabal view
@@ -1,7 +1,7 @@ name: stache-version: 2.1.0+version: 2.1.1 cabal-version: 1.18-tested-with: GHC==8.2.2, GHC==8.4.4, GHC==8.6.5+tested-with: GHC==8.4.4, GHC==8.6.5, GHC==8.8.3 license: BSD3 license-file: LICENSE.md author: Mark Karpov <markkarpov92@gmail.com>@@ -29,15 +29,15 @@ library build-depends: aeson >= 0.11 && < 1.5- , base >= 4.10 && < 5.0+ , base >= 4.11 && < 5.0 , bytestring >= 0.10 && < 0.11 , containers >= 0.5 && < 0.7 , deepseq >= 1.4 && < 1.5 , directory >= 1.2 && < 1.4 , filepath >= 1.2 && < 1.5- , megaparsec >= 7.0 && < 8.0+ , megaparsec >= 7.0 && < 9.0 , mtl >= 2.1 && < 3.0- , template-haskell >= 2.10 && < 2.15+ , template-haskell >= 2.11 && < 2.16 , text >= 1.2 && < 1.3 , unordered-containers >= 0.2.5 && < 0.3 , vector >= 0.11 && < 0.13@@ -56,7 +56,6 @@ -Wincomplete-record-updates -Wincomplete-uni-patterns -Wnoncanonical-monad-instances- -Wnoncanonical-monadfail-instances default-language: Haskell2010 test-suite tests@@ -64,13 +63,13 @@ hs-source-dirs: tests type: exitcode-stdio-1.0 build-depends: aeson >= 0.11 && < 1.5- , base >= 4.10 && < 5.0+ , base >= 4.11 && < 5.0 , containers >= 0.5 && < 0.7 , hspec >= 2.0 && < 3.0 , hspec-megaparsec >= 2.0 && < 3.0- , megaparsec >= 7.0 && < 8.0+ , megaparsec >= 7.0 && < 9.0 , stache- , template-haskell >= 2.10 && < 2.15+ , template-haskell >= 2.11 && < 2.16 , text >= 1.2 && < 1.3 other-modules: Text.Mustache.Compile.THSpec , Text.Mustache.ParserSpec@@ -88,12 +87,12 @@ hs-source-dirs: mustache-spec type: exitcode-stdio-1.0 build-depends: aeson >= 0.11 && < 1.5- , base >= 4.10 && < 5.0+ , base >= 4.11 && < 5.0 , bytestring >= 0.10 && < 0.11 , containers >= 0.5 && < 0.7 , file-embed , hspec >= 2.0 && < 3.0- , megaparsec >= 7.0 && < 8.0+ , megaparsec >= 7.0 && < 9.0 , stache , text >= 1.2 && < 1.3 , yaml >= 0.8 && < 0.12@@ -111,7 +110,7 @@ , base >= 4.10 && < 5.0 , criterion >= 0.6.2.1 && < 1.6 , deepseq >= 1.4 && < 1.5- , megaparsec >= 7.0 && < 8.0+ , megaparsec >= 7.0 && < 9.0 , stache , text >= 1.2 && < 1.3 if flag(dev)
tests/Text/Mustache/Compile/THSpec.hs view
@@ -10,18 +10,18 @@ import Test.Hspec -#if MIN_VERSION_template_haskell(2,11,0)-import Data.Semigroup ((<>)) import Text.Mustache.Type import qualified Data.Map as M import qualified Text.Mustache.Compile.TH as TH++#if !MIN_VERSION_base(4,13,0)+import Data.Semigroup ((<>)) #endif main :: IO () main = hspec spec spec :: Spec-#if MIN_VERSION_template_haskell(2,11,0) spec = do describe "mustache" $ it "compiles template using QuasiQuotes at compile time" $@@ -52,6 +52,3 @@ barTemplate :: Template barTemplate = Template "bar" $ M.singleton "bar" [TextBlock "And this is the ‘bar’.\n"]-#else-spec = return ()-#endif
tests/Text/Mustache/ParserSpec.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} module Text.Mustache.ParserSpec@@ -5,12 +6,15 @@ , spec ) where -import Data.Semigroup ((<>)) import Test.Hspec import Test.Hspec.Megaparsec import Text.Megaparsec import Text.Mustache.Parser import Text.Mustache.Type++#if !MIN_VERSION_base(4,13,0)+import Data.Semigroup ((<>))+#endif main :: IO () main = hspec spec
tests/Text/Mustache/RenderSpec.hs view
@@ -138,6 +138,14 @@ , ("partial", [TextBlock "one\ntwo\nthree"]) ] in renderMustache template Null `shouldBe` " one\n two\n three*"+ context "when rendering a nested partial" $+ it "renders outer partial correctly" $+ let template = Template "outer" $+ M.fromList [ ("inner", [TextBlock "x"])+ , ("middle", [Partial "inner" (Just $ mkPos 1)])+ , ("outer", [Partial "middle" (Just $ mkPos 1)])+ ]+ in renderMustache template Null `shouldBe` "x" context "when using dotted keys inside a section" $ it "it should be equivalent to access via one more section" $ r [ Section (key "things")
tests/Text/Mustache/TypeSpec.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} module Text.Mustache.TypeSpec@@ -5,10 +6,13 @@ , spec ) where -import Data.Semigroup ((<>)) import Test.Hspec import Text.Mustache.Type import qualified Data.Map as M++#if !MIN_VERSION_base(4,13,0)+import Data.Semigroup ((<>))+#endif main :: IO () main = hspec spec