sitepipe-0.4.0.2: A simple to understand static site generator
Safe HaskellNone
LanguageHaskell2010

SitePipe.Pipes

Synopsis

Documentation

site :: SiteM () -> IO () Source #

Build a site generator from a set of rules embedded in a SiteM. Use this in your main function.

main :: IO ()
main = site $ do
  posts <- resourceLoader markdownReader ["posts/*.md"]
  writeTemplate "templates/post.html" posts

siteWithGlobals :: Value -> SiteM () -> IO () Source #

Like site, but allows you to pass an Value Object which consists of an environment which is available inside your templates.

This is useful for globally providing utility functions for use in your templates.

import qualified Text.Mustache as MT
import qualified Text.Mustache.Types as MT
utilityFuncs :: MT.Value
utilityFuncs = MT.object
  ["truncate" MT.~> MT.overText (T.take 30)
  ]

main :: IO ()
main = siteWithGlobals utilityFuncs $ do
 -- your site ...
<!-- in your template -->
{{#truncate}}
  Anything inside this block will be truncated to 30 chars.
  {{vars}} are interpolated before applying the function.
{{/truncate}}