module Lucid.Scaffold where
import Lucid
import Lucid.Base
import qualified Data.Text as T
import Data.Monoid
data WebPage m = WebPage { pageTitle :: T.Text
, favicon :: T.Text
, metaVars :: (HtmlT m ())
, initScripts :: (HtmlT m ())
, beforeStylesScripts :: (HtmlT m ())
, styles :: (HtmlT m ())
, afterStylesScripts :: (HtmlT m ())
, bodyScripts :: (HtmlT m ())
}
instance Monad m => Monoid (WebPage m) where
mempty = WebPage "" "" mempty mempty mempty mempty mempty mempty
mappend x _ = x
template :: Monad m =>
WebPage m
-> HtmlT m ()
-> HtmlT m ()
template page content = doctypehtml_ $ mconcat $
[ head_ [] $ mconcat $
[ initScripts page
, title_ $ toHtmlRaw $ pageTitle page
, metaVars page
, link_ [ rel_ "icon"
, href_ $ favicon page
]
, beforeStylesScripts page
, styles page
, afterStylesScripts page
]
, body_ [] $ mconcat $
[ content
, bodyScripts page
]
]