ginger 0.1.6.0 → 0.1.7.0
raw patch · 3 files changed
+28/−2 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ginger.cabal +1/−1
- src/Text/Ginger/Parse.hs +9/−1
- src/Text/Ginger/Run.hs +18/−0
ginger.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: ginger-version: 0.1.6.0+version: 0.1.7.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.
src/Text/Ginger/Parse.hs view
@@ -438,7 +438,7 @@ optional . ignore . char $ '\n' expressionP :: Monad m => Parser m Expression-expressionP = comparativeExprP+expressionP = booleanExprP operativeExprP :: forall m. Monad m => Parser m Expression -> [ (String, Text) ] -> Parser m Expression operativeExprP operandP operators = do@@ -458,6 +458,14 @@ rhs <- operandP spaces return (\lhs -> CallE (VarE funcName) [(Nothing, lhs), (Nothing, rhs)])++booleanExprP :: Monad m => Parser m Expression+booleanExprP =+ operativeExprP+ comparativeExprP+ [ ("||", "any")+ , ("&&", "all")+ ] comparativeExprP :: Monad m => Parser m Expression comparativeExprP =
src/Text/Ginger/Run.hs view
@@ -128,11 +128,14 @@ scope = [ ("raw", fromFunction gfnRawHtml) , ("abs", fromFunction . unaryNumericFunc 0 $ Prelude.abs)+ , ("any", fromFunction gfnAny)+ , ("all", fromFunction gfnAll) -- TODO: batch , ("ceil", fromFunction . unaryNumericFunc 0 $ Prelude.fromIntegral . Prelude.ceiling) , ("capitalize", fromFunction . variadicStringFunc $ mconcat . Prelude.map capitalize) , ("center", fromFunction gfnCenter) , ("concat", fromFunction . variadicStringFunc $ mconcat)+ , ("contains", fromFunction gfnContains) , ("default", fromFunction gfnDefault) , ("difference", fromFunction . variadicNumericFunc 0 $ difference) , ("equals", fromFunction gfnEquals)@@ -175,6 +178,12 @@ | asBoolean x = return x | otherwise = gfnDefault xs + gfnAny :: Function (Run m)+ gfnAny xs = return . toGVal $ Prelude.any (asBoolean . snd) xs++ gfnAll :: Function (Run m)+ gfnAll xs = return . toGVal $ Prelude.all (asBoolean . snd) xs+ gfnEquals :: Function (Run m) gfnEquals [] = return $ toGVal True gfnEquals (x:[]) = return $ toGVal True@@ -186,6 +195,15 @@ gfnNEquals (x:[]) = return $ toGVal True gfnNEquals (x:xs) = return . toGVal $ Prelude.any (not . (snd x `looseEquals`) . snd) xs++ gfnContains :: Function (Run m)+ gfnContains [] = return $ toGVal False+ gfnContains (list:elems) =+ let rawList = fromMaybe [] . asList . snd $ list+ rawElems = fmap snd elems+ e `isInList` xs = Prelude.any (looseEquals e) xs+ es `areInList` xs = Prelude.all (`isInList` xs) es+ in return . toGVal $ rawElems `areInList` rawList looseEquals :: GVal (Run m) -> GVal (Run m) -> Bool looseEquals a b