ginger 0.3.8.0 → 0.3.9.0
raw patch · 6 files changed
+5/−160 lines, 6 filesdep ~timePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: time
API changes (from Hackage documentation)
- Text.Ginger.AST: SwitchS :: Expression -> [(Expression, Statement)] -> Statement -> Statement
Files
- ginger.cabal +3/−5
- src/Text/Ginger/AST.hs +0/−1
- src/Text/Ginger/Parse.hs +0/−21
- src/Text/Ginger/Run.hs +0/−18
- test/Text/Ginger/SimulationTests.hs +2/−25
- test/fixtures/silly-locale.json +0/−90
ginger.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: ginger-version: 0.3.8.0+version: 0.3.9.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.@@ -15,9 +15,7 @@ category: Text build-type: Simple -- extra-source-files:-data-files: test/fixtures/*.json cabal-version: >=1.10-bug-reports: https://github.com/tdammers/ginger/issues library exposed-modules: Text.Ginger@@ -33,7 +31,7 @@ other-modules: Text.Ginger.Run.Type , Text.Ginger.Run.Builtins -- other-extensions:- build-depends: base >=4.5 && <5+ build-depends: base >=4.8 && <5 , aeson , bytestring , data-default >= 0.5@@ -44,7 +42,7 @@ , safe >= 0.3 , scientific >= 0.3 , text- , time+ , time >= 0.1.6.0 , transformers >= 0.3 , unordered-containers >= 0.2.5 , utf8-string
src/Text/Ginger/AST.hs view
@@ -39,7 +39,6 @@ | LiteralS Html -- ^ Literal output (anything outside of any tag) | InterpolationS Expression -- ^ {{ expression }} | IfS Expression Statement Statement -- ^ {% if expression %}statement{% else %}statement{% endif %}- | SwitchS Expression [(Expression, Statement)] Statement -- ^ {% switch expression %}{% case expression %}statement{% endcase %}...{% default %}statement{% enddefault %}{% endswitch %} | ForS (Maybe VarName) VarName Expression Statement -- ^ {% for index, varname in expression %}statement{% endfor %} | SetVarS VarName Expression -- ^ {% set varname = expr %} | DefMacroS VarName Macro -- ^ {% macro varname %}statements{% endmacro %}
src/Text/Ginger/Parse.hs view
@@ -197,7 +197,6 @@ statementP = interpolationStmtP <|> commentStmtP <|> ifStmtP- <|> switchStmtP <|> setStmtP <|> forStmtP <|> includeP@@ -258,25 +257,6 @@ -- No endif here: the parent {% if %} owns that one. return $ IfS condExpr trueStmt falseStmt -switchStmtP :: Monad m => Parser m Statement-switchStmtP = do- pivotExpr <- try $ fancyTagP "switch" expressionP- cases <- many switchCaseP- def <- option NullS $ switchDefaultP- simpleTagP "endswitch"- return $ SwitchS pivotExpr cases def--switchCaseP :: Monad m => Parser m (Expression, Statement)-switchCaseP = do- cmpExpr <- try $ fancyTagP "case" expressionP- body <- statementsP- simpleTagP "endcase"- return (cmpExpr, body)--switchDefaultP :: Monad m => Parser m Statement-switchDefaultP = do- try (simpleTagP "default") *> statementsP <* simpleTagP "enddefault"- setStmtP :: Monad m => Parser m Statement setStmtP = fancyTagP "set" setStmtInnerP @@ -726,7 +706,6 @@ c2 <- anyChar case c2 of 'n' -> return '\n'- 'r' -> return '\r' 'b' -> return '\b' 'v' -> return '\v' '0' -> return '\0'
src/Text/Ginger/Run.hs view
@@ -250,24 +250,6 @@ cond <- runExpression condExpr runStatement $ if toBoolean cond then true else false -runStatement (SwitchS pivotExpr cases def) = do- pivot <- runExpression pivotExpr- let branches =- [ \cont -> do- cond <- runExpression condExpr- if pivot `looseEquals` cond- then runStatement body- else cont- | (condExpr, body)- <- cases- ] ++- [ Prelude.const (runStatement def)- ]- go branches- where- go [] = return ()- go (x:xs) = x (go xs)- runStatement (SetVarS name valExpr) = do val <- runExpression valExpr setVar name val
test/Text/Ginger/SimulationTests.hs view
@@ -38,12 +38,8 @@ [] [] "- {%- set x=1 -%} -" "--" ] , testGroup "Literals"- [ testGroup "Strings"- [ testCase "String: \"foobar\"" $ mkTestHtml- [] [] "{{ \"foobar\" }}" "foobar"- , testCase "String: \"\\r\\n\\t\\b\"" $ mkTestHtml- [] [] "{{ \"\\r\\n\\t\\b\" }}" "\r\n\t\b"- ]+ [ testCase "String: \"foobar\"" $ mkTestHtml+ [] [] "{{ \"foobar\" }}" "foobar" , testGroup "Numbers" [ testCase "123" $ mkTestHtml [] [] "{{ 123 }}" "123"@@ -170,25 +166,6 @@ mkTestHtml [] [] "{% if false %}yes{% elif false %}maybe{% else %}no{% endif %}" "no" , testCase "if false then \"yes\" else if true then \"maybe\" else \"no\"" $ do mkTestHtml [] [] "{% if false %}yes{% elif true %}maybe{% else %}no{% endif %}" "maybe"- ]- , testGroup "Switch"- [ testCase "switch 1 of 1, 2, default" $ do- mkTestHtml [] []- ( "{% switch 1 %}\n" ++- "{% case 1 %}One{% endcase %}\n" ++- "{% case 2 %}Two{% endcase %}\n" ++- "{% default %}Default{% enddefault %}\n" ++- "{% endswitch %}\n"- )- "One"- , testCase "switch 1 of 1, 2" $ do- mkTestHtml [] []- ( "{% switch 1 %}\n" ++- "{% case 1 %}One{% endcase %}\n" ++- "{% case 2 %}Two{% endcase %}\n" ++- "{% endswitch %}\n"- )- "One" ] , testGroup "Comparisons" [ testCase "if 1 == 1 then \"yes\" else \"no\"" $ do
− test/fixtures/silly-locale.json
@@ -1,90 +0,0 @@-{- "dateTimeFmt" : "It be %A, in the year %y, the clock striketh %H",- "wDays" : [- [- "The Day Of Sunshine",- "Sun"- ],- [- "The Day Of Monning",- "Mon"- ],- [- "The Day Of Two",- "Tue"- ],- [- "The Midst Of The Week",- "Wed"- ],- [- "The Day Of Thor",- "Thu"- ],- [- "The Day Of Freya",- "Fri"- ],- [- "The Day Of Saturn",- "Sat"- ]- ],- "amPm" : [- "Morning",- "Evening"- ],- "timeFmt" : "%H o'clock",- "months" : [- [- "January",- "Jan"- ],- [- "February",- "Feb"- ],- [- "March",- "Mar"- ],- [- "April",- "Apr"- ],- [- "May",- "May"- ],- [- "June",- "Jun"- ],- [- "July",- "Jul"- ],- [- "August",- "Aug"- ],- [- "September",- "Sep"- ],- [- "October",- "Oct"- ],- [- "November",- "Nov"- ],- [- "December",- "Dec"- ]- ],- "time12Fmt" : "%I:%M:%S %p",- "dateFmt" : "%d-%m, %y"-}