StrappedTemplates: General purpose templates in haskell

[ bsd3, library, text ] [ Propose Tags ]

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])
       , ("ioTime", Func (\_ -> (liftIO $ getCurrentTime) >>= (\c -> return $ LitText $ T.pack $ show c)))
       ]

 main :: IO ()
 main = do
   tmpls <- templateStoreFromDirectory "benchmarks/strapped_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
 ${ ioTime }
 
 {$ for i in is $}
     ${ i }
 {$ endfor $}

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.1.1.0, 0.2.0.0, 0.2.0.1, 0.2.0.2
Dependencies base (>=4.7 && <4.8), blaze-builder (>=0.3 && <0.4), containers (>=0.5 && <0.6), filemanip (>=0.3.6 && <0.3.7), filepath (>=1.3 && <1.4), mtl (>=2.1 && <2.3), parsec (>=3.1 && <3.2), text (>=1.0 && <1.2), transformers (>=0.4 && <0.5) [details]
License BSD-3-Clause
Author Kyle Hanson
Maintainer me@khanson.io
Category Text
Home page https://github.com/hansonkd/StrappedTemplates
Uploaded by hansonkd at 2014-08-03T06:04:07Z
Distributions
Reverse Dependencies 2 direct, 0 indirect [details]
Downloads 3839 total (13 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]