The StrappedTemplates package

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain]

Easy templating in haskell.

 import Control.Monad.IO.Class
 import qualified Blaze.ByteString.Builder as B
 import qualified Data.Text.Lazy as T
 import Data.Time

 import Text.Strapped

 makeBucket :: Integer -> InputBucket IO
 makeBucket i = bucketFromList
       [ ("is", List $ map (LitVal . LitInteger) [1..i])
       , ("is_truthy", LitVal $ LitInteger i)
       , ("ioTime", Func (\_ -> (liftIO $ getCurrentTime) >>= (\c -> return $ LitText $ T.pack $ show c)))
       ]

 main :: IO ()
 main = do
   tmpls <- templateStoreFromDirectory "examples/templates" ".strp"
   case tmpls of
     Left err -> print err
     Right store -> do
       rendered <- render (putStore store defaultConfig) (makeBucket 2) "base_simple.strp"
       either (print) (print . B.toByteString) rendered
 {$ inherits base.strp $}
 
 {$ isblock body $}
 
 An IO function to find the current time: ${ ioTime }
 
 {$ if is_truthy $}
     {$ inherits base.strp $}
     {$ isblock body $}
         Any block level can inherit from another template and override blocks.
     {$ endisblock $}
 {$ else $}
     Don't show me.
 {$ endif $}
 
 Taken from an includes:
 {$ include includes/includes.strp $}
 
 Lets count...
 {$ for i in is $}
     ${ i }
 {$ endfor $}
 
 {$ endisblock $}

Properties

Versions0.1.0.0, 0.1.1.0, 0.1.1.0, 0.2.0.0, 0.2.0.1, 0.2.0.2
Change logNone available
Dependenciesbase (==4.7.*), blaze-builder (==0.3.*), bytestring (==0.10.*), containers (==0.5.*), filemanip (==0.3.6.*), filepath (==1.3.*), mtl (>=2.1 && <2.3), parsec (==3.1.*), text (>=1.0 && <1.2), transformers (==0.4.*) [details]
LicenseBSD3
AuthorKyle Hanson
Maintainerme@khanson.io
CategoryText
Home pagehttps://github.com/hansonkd/StrappedTemplates
UploadedSun Aug 3 16:30:57 UTC 2014 by hansonkd

Modules

[Index]

Downloads

Maintainers' corner

For package maintainers and hackage trustees