packages feed

Bravo 0.1.0 → 0.1.0.1

raw patch · 5 files changed

+92/−33 lines, 5 filesdep +sybdep ~basedep ~haskell-src-metadep ~parsec

Dependencies added: syb

Dependency ranges changed: base, haskell-src-meta, parsec, template-haskell

Files

Bravo.cabal view
@@ -1,5 +1,5 @@ Name:          Bravo-Version:       0.1.0+Version:       0.1.0.1 Cabal-Version: >= 1.6 Build-Type:    Simple License:       BSD3@@ -17,21 +17,42 @@                no extra file access or error handling at runtime is necessary.                .                Additional features include the definition of multiple templates per file,-               conditional template evaluation, embeddeding of Haskell expressions and customized+               conditional template evaluation, embedding of Haskell expressions and customized                data type generation. Category:      Text-Tested-With:   GHC == 6.10.4+Tested-With:   GHC == 6.10.4, GHC == 6.12.1  Extra-Source-Files: src/Examples/Example01.hs,-                    src/Examples/Example01.tpl+                    src/Examples/Example01.tpl,+                    src/Examples/Example02.hs,+                    src/Examples/Example02Templates.hs,+                    src/Examples/Example02.tpl +Flag base4+    Description: base >= 4.0+    Default: True++Flag newTH+    Description: This fixes incompatibilities between different template-haskell and+                 haskell-src-meta versions.+    Default: True+ Library-    Build-Depends:      base              >= 3.0     && <5,-                        mtl               >= 1.1.0.2 && <1.2,-                        haskell-src-exts  >= 1.2     && <2,-                        haskell-src-meta  >= 0.0.6   && <0.1,-                        template-haskell  >= 2.3.0.1 && <2.4,-                        parsec            >= 2.1.0.1 && <3+    if flag(base4)+        Build-Depends:  base              >= 4       && < 5,+                        syb               >= 0.1.0.1 && < 0.2+    else+        Build-Depends:  base              >= 3.0.3   && < 4+    Build-Depends:      mtl               >= 1.1.0.2 && < 1.2,+                        haskell-src-exts  >= 1.2     && < 2,+                        parsec            >= 2.1.0.1 && < 3.0+    if flag(newTH)+        Build-Depends:  haskell-src-meta  >= 0.1     && < 0.2,+                        template-haskell  >= 2.4     && < 2.5+    else+        Build-Depends:  haskell-src-meta  >= 0.0.6   && < 0.1,+                        template-haskell  >= 2.3.0.1 && < 2.4+     Exposed-Modules:    Text.Bravo     Other-Modules:      Text.Bravo.Parser                         Text.Bravo.Syntax
src/Examples/Example01.hs view
@@ -1,23 +1,23 @@-{-# LANGUAGE TemplateHaskell #-}
-module Main (main) where
-
-import Text.Bravo
-
-
-$(mkTemplatesFromFile "Example01.tpl")
-
-main :: IO ()
-main = do
-    let users = [ newUser "Peter" "Miller" 30 True,
-                  newUser "Sandra" "Thompson" 24 False,
-                  newUser "Linda" "Scott" 38 True ]
-        tpl   = show TplMain { mainUsers = concatMap show users }
-    writeFile "Example01.html" tpl
-
-newUser :: String -> String -> Int -> Bool -> TplUser
-newUser fname lname age married = TplUser {
-                                      userFirstName = fname,
-                                      userLastName = lname,
-                                      userAge = age,
-                                      userMarried = married
-                                  }
+{-# LANGUAGE TemplateHaskell #-}+module Main (main) where++import Text.Bravo+++$(mkTemplatesFromFile "Example01.tpl")++main :: IO ()+main = do+    let users = [ newUser "Peter" "Miller" 30 True,+                  newUser "Sandra" "Thompson" 24 False,+                  newUser "Linda" "Scott" 38 True ]+        tpl   = show TplMain { mainUsers = concatMap show users }+    writeFile "Example01.html" tpl++newUser :: String -> String -> Int -> Bool -> TplUser+newUser fname lname age married = TplUser {+                                      userFirstName = fname,+                                      userLastName = lname,+                                      userAge = age,+                                      userMarried = married+                                  }
+ src/Examples/Example02.hs view
@@ -0,0 +1,13 @@+module Main (main) where++import Text.Bravo+import System.IO.Unsafe (unsafePerformIO)++import Example02Templates++main :: IO ()+main = return ()++-- Doing unsafe stuff here is allowed+unsafe :: String+unsafe = unsafePerformIO $ return "Hello world!"
+ src/Examples/Example02.tpl view
@@ -0,0 +1,13 @@++    The safe template++{{tpl safe}}+    {{: "Hello" ++ " world!" }}+{{endtpl}}+++    The unsafe template++{{tpl unsafe}}+    {{: unsafePerformIO (putStrLn "Doing some very bad stuff ..." >> return "Hello world!") }}+{{endtpl}}
+ src/Examples/Example02Templates.hs view
@@ -0,0 +1,12 @@+{-# LANGUAGE TemplateHaskell #-}+module Example02Templates (+        TplSafe (..),+        TplUnsafe (..)+    )+where++import Text.Bravo++--import System.IO.Unsafe (unsafePerformIO)++$(mkTemplatesFromFile "Example02.tpl")