packages feed

ginger 0.2.3.0 → 0.2.4.0

raw patch · 4 files changed

+23/−3 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Text.Ginger.AST: TernaryE :: Expression -> Expression -> Expression -> Expression

Files

ginger.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                ginger-version:             0.2.3.0+version:             0.2.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,6 @@                , vector   hs-source-dirs:      src   default-language:    Haskell2010-  GHC-options: -O0  executable ginger     main-is: GingerCLI.hs
src/Text/Ginger/AST.hs view
@@ -59,4 +59,5 @@     | MemberLookupE Expression Expression -- ^ foo[bar] (also dot access)     | CallE Expression [(Maybe Text, Expression)] -- ^ foo(bar=baz, quux)     | LambdaE [Text] Expression -- ^ (foo, bar) -> expr+    | TernaryE Expression Expression Expression -- ^ expr ? expr : expr     deriving (Show)
src/Text/Ginger/Parse.hs view
@@ -438,7 +438,7 @@     optional . ignore . char $ '\n'  expressionP :: Monad m => Parser m Expression-expressionP = lambdaExprP <|> booleanExprP+expressionP = lambdaExprP <|> ternaryExprP  lambdaExprP :: Monad m => Parser m Expression lambdaExprP = do@@ -472,6 +472,22 @@             rhs <- operandP             spaces             return (\lhs -> CallE (VarE funcName) [(Nothing, lhs), (Nothing, rhs)])++ternaryExprP :: Monad m => Parser m Expression+ternaryExprP = do+    condition <- booleanExprP+    spaces+    ternaryTailP condition <|> return condition++ternaryTailP :: Monad m => Expression -> Parser m Expression+ternaryTailP condition = do+    char '?'+    spaces+    yesBranch <- expressionP+    char ':'+    spaces+    noBranch <- expressionP+    return $ TernaryE condition yesBranch noBranch  booleanExprP :: Monad m => Parser m Expression booleanExprP =
src/Text/Ginger/Run.hs view
@@ -754,6 +754,10 @@                 setVar argName arg             runExpression body     return $ fromFunction fn+runExpression (TernaryE condition yes no) = do+    condVal <- runExpression condition+    let expr = if asBoolean condVal then yes else no+    runExpression expr  -- | Helper function to output a HTML value using whatever print function the -- context provides.