packages feed

mustache 0.5.0.0 → 0.5.1.0

raw patch · 6 files changed

+71/−33 lines, 6 filesdep −tagsoupPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies removed: tagsoup

API changes (from Hackage documentation)

- Text.Mustache.Types: instance Text.Mustache.Types.ToMustache a => Text.Mustache.Types.ToMustache [a]
+ Text.Mustache.Types: instance Text.Mustache.Types.ToMustache GHC.Integer.Type.Integer
+ Text.Mustache.Types: instance Text.Mustache.Types.ToMustache GHC.Types.Double
+ Text.Mustache.Types: instance Text.Mustache.Types.ToMustache GHC.Types.Float
+ Text.Mustache.Types: instance Text.Mustache.Types.ToMustache GHC.Types.Int
+ Text.Mustache.Types: instance Text.Mustache.Types.ToMustache α => Text.Mustache.Types.ToMustache [α]

Files

CHANGELOG.md view
@@ -1,5 +1,10 @@ # Mustache library changelog +## v0.5.1.0rc-7++- Removed dependency tagsoup+- Added ToMustache instances for some numbers+ ## v0.5.0.0rc-6  - Removed any dependency on ghc 7.10-type OverlappingInstances
mustache.cabal view
@@ -1,5 +1,5 @@ name:                mustache-version:             0.5.0.0+version:             0.5.1.0 synopsis:            A mustache template parser library. description:   Allows parsing and rendering template files with mustache markup. See the@@ -30,7 +30,7 @@   type:     git   branch:   master   location: git://github.com/JustusAdam/mustache.git-  tag:      v0.5.0.0rc-6+  tag:      v0.5.1.0rc-7   @@ -42,22 +42,21 @@                        Text.Mustache.Render   other-modules:       Text.Mustache.Internal   other-extensions:    NamedFieldPuns, OverloadedStrings, LambdaCase, TupleSections-  build-depends:       base >=4.7 && <5,-                       text >=1.2 && <1.3,-                       parsec >=3.1 && <3.2,-                       mtl >=2.2 && <2.3,-                       either,-                       aeson,-                       unordered-containers,-                       vector,-                       tagsoup,-                       bytestring,-                       directory,-                       filepath,-                       scientific,-                       base-unicode-symbols,-                       ja-base-extra >= 0.2.1,-                       containers+  build-depends:       base >=4.7 && <5+                     , text >=1.2 && <1.3+                     , parsec >=3.1 && <3.2+                     , mtl >=2.2 && <2.3+                     , either+                     , aeson+                     , unordered-containers+                     , vector+                     , bytestring+                     , directory+                     , filepath+                     , scientific+                     , base-unicode-symbols+                     , ja-base-extra >= 0.2.1+                     , containers   hs-source-dirs:      src/lib   default-language:    Haskell2010   ghc-options:
src/lib/Text/Mustache/Compile.hs view
@@ -23,7 +23,7 @@ import           Data.Bool import           Data.Function.JAExtra import           Data.HashMap.Strict        as HM-import           Data.Monoid.Unicode        ((⊕), (∅))+import           Data.Monoid.Unicode        ((∅)) import           Data.Text                  hiding (concat, find, map, uncons) import qualified Data.Text.IO               as TIO import           Prelude.Unicode@@ -67,7 +67,7 @@ compileTemplateWithCache searchSpace templates initName =   runEitherT $ evalStateT (compile' initName) $ flattenPartials templates   where-    compile' :: FilePath+    compile' ∷ FilePath              → StateT                 (HM.HashMap String Template)                 (EitherT ParseError IO)
src/lib/Text/Mustache/Internal.hs view
@@ -6,11 +6,37 @@ Maintainer  : dev@justus.science Stability   : experimental Portability : POSIX++escapeXML and xmlEntities curtesy to the tagsoup library. -} {-# LANGUAGE UnicodeSyntax #-}-module Text.Mustache.Internal (uncons) where+module Text.Mustache.Internal (uncons, escapeXMLText) where  -uncons ∷ [a] → Maybe (a, [a])+import           Data.Char       (ord)+import qualified Data.IntMap     as IntMap+import qualified Data.Text       as T+import           Prelude.Unicode+++uncons ∷ [α] → Maybe (α, [α]) uncons []     = Nothing uncons (x:xs) = return (x, xs)+++escapeXMLText :: T.Text -> T.Text+escapeXMLText = T.pack ∘ escapeXML ∘ T.unpack+++escapeXML :: String -> String+escapeXML = concatMap $ \x -> IntMap.findWithDefault [x] (ord x) mp+    where mp = IntMap.fromList [(ord b, "&"++a++";") | (a,[b]) <- xmlEntities]+++xmlEntities :: [(String, String)]+xmlEntities =+  [ ("quot", "\"")+  , ("amp" , "&")+  , ("lt"  , "<")+  , ("gt"  , ">")+  ]
src/lib/Text/Mustache/Render.hs view
@@ -34,7 +34,6 @@ import qualified Data.Vector            as V import           Prelude                hiding (length, lines, unlines) import           Prelude.Unicode-import           Text.HTML.TagSoup      (escapeHTML) import           Text.Mustache.Internal import           Text.Mustache.Types @@ -111,7 +110,7 @@     substitute' context (Variable escaped (NamedData varName)) =       maybe         (∅)-        (if escaped then escapeHTML else id)+        (if escaped then escapeXMLText else id)         $ toString <$> search context varName      -- substituting a partial@@ -149,9 +148,9 @@ search ∷ Context Value → [Key] → Maybe Value search _ [] = Nothing search ctx keys@(_:nextKeys) = go ctx keys ≫= innerSearch nextKeys-  where +  where   go _ [] = Nothing-  go (Context parents focus) val@(x:_) = +  go (Context parents focus) val@(x:_) =     ( case focus of       (Object o) → HM.lookup x o       _          → Nothing
src/lib/Text/Mustache/Types.hs view
@@ -76,7 +76,7 @@ data Context α = Context [α] α   deriving (Eq, Show, Ord) --- | Internal value STree+-- | Internal value representation data Value   = Object Object   | Array  Array@@ -97,17 +97,26 @@   show Null       = "null"  -- | Conversion class------ Note that some instances of this class overlap delierately to provide--- maximum flexibility instances while preserving maximum efficiency. class ToMustache ω where   toMustache ∷ ω → Value   listToMustache ∷ [ω] → Value   listToMustache = Array ∘ V.fromList ∘ fmap toMustache +instance ToMustache Float where+  toMustache = Number ∘ fromFloatDigits++instance ToMustache Double where+  toMustache = Number ∘ fromFloatDigits++instance ToMustache Integer where+  toMustache = Number ∘ fromInteger++instance ToMustache Int where+  toMustache = toMustache . toInteger+ instance ToMustache Char where-  toMustache = toMustache . (:[])-  listToMustache = String . pack+  toMustache = toMustache ∘ (:[])+  listToMustache = String ∘ pack  instance ToMustache Value where   toMustache = id@@ -127,7 +136,7 @@ instance ToMustache Scientific where   toMustache = Number -instance ToMustache a => ToMustache [a] where+instance ToMustache α ⇒ ToMustache [α] where   toMustache = listToMustache  instance ToMustache ω ⇒ ToMustache (V.Vector ω) where