ginger 0.8.3.0 → 0.8.4.0
raw patch · 5 files changed
+23/−2 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Text.Ginger.Run.Builtins: gfnApply :: Monad m => Function (Run p m h)
Files
- CHANGELOG.md +4/−0
- ginger.cabal +2/−2
- src/Text/Ginger/Run.hs +1/−0
- src/Text/Ginger/Run/Builtins.hs +10/−0
- test/Text/Ginger/SimulationTests.hs +6/−0
CHANGELOG.md view
@@ -1,3 +1,7 @@+## 0.8.4.0++- Added builtin `apply`, making it possible to pass argument lists as arrays+ ## 0.8.3.0 - Added builtin `regex` module for POSIX regular expressions support
ginger.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: ginger-version: 0.8.3.0+version: 0.8.4.0 synopsis: An implementation of the Jinja2 template language in Haskell description: Ginger is Jinja, minus the most blatant pythonisms. Wants to be feature complete, but isn't quite there yet.@@ -44,7 +44,7 @@ , http-types >= 0.8 && (< 0.11 || >= 0.12) , mtl >= 2.2 , parsec >= 3.0- , regex-tdfa >=1.2.3.1 && <=1.3+ , regex-tdfa >=1.2.3 && <=1.3 , safe >= 0.3 , scientific >= 0.3 , text
src/Text/Ginger/Run.hs view
@@ -130,6 +130,7 @@ , ("abs", fromFunction . unaryNumericFunc 0 $ Prelude.abs) , ("any", fromFunction gfnAny) , ("all", fromFunction gfnAll)+ , ("apply", fromFunction gfnApply) -- TODO: batch , ("capitalize", fromFunction . variadicStringFunc $ mconcat . Prelude.map capitalize) , ("ceil", fromFunction . unaryNumericFunc 0 $ Prelude.fromIntegral . Prelude.ceiling)
src/Text/Ginger/Run/Builtins.hs view
@@ -156,6 +156,16 @@ inDict needle haystack = isJust $ lookupKey (asText needle) haystack +gfnApply :: Monad m => Function (Run p m h)+gfnApply [] = return def+gfnApply [_] = return def+gfnApply ((_, fg):(_,a):xs) =+ case asFunction fg of+ Nothing -> throwHere $ ArgumentsError (Just "apply") "Tried to call something that isn't a function"+ Just f ->+ let args = (fmap (Nothing,) . fromMaybe [] . asList $ a) ++ xs+ in f args+ gfnEquals :: Monad m => Function m gfnEquals [] = return $ toGVal True gfnEquals [x] = return $ toGVal True
test/Text/Ginger/SimulationTests.hs view
@@ -952,6 +952,12 @@ "{% if 'foo'|in({'bar': false, 'baz': false, 'fooq': false}) %}yes{% else %}no{% endif %}" "no" ]+ , testGroup "\"apply\""+ [ testCase "sum" $ do+ mkTestHtml [] []+ "{{ apply(sum, [1,2,3]) }}"+ "6"+ ] ] , testGroup "Setting variables" [ testCase "plain" $ do