Safe Haskell | None |
---|
- class HasTemplates hs where
- defaultLayout :: Controller hs (Maybe Template)
- viewDirectory :: Controller hs FilePath
- functionMap :: Controller hs FunctionMap
- getTemplate :: FilePath -> Controller hs Template
- render :: ToJSON a => FilePath -> a -> Controller hs ()
- renderPlain :: ToJSON a => FilePath -> a -> Controller hs ()
- renderLayout :: ToJSON a => FilePath -> FilePath -> a -> Controller hs ()
- renderLayout' :: ToJSON a => Template -> FilePath -> a -> Controller hs ()
- defaultGetTemplate :: HasTemplates hs => FilePath -> Controller hs Template
- defaultRender :: (HasTemplates hs, ToJSON a) => FilePath -> a -> Controller hs ()
- defaultFunctionMap :: FunctionMap
- fromList :: (Eq k, Hashable k) => [(k, v)] -> HashMap k v
- newtype Function = Function {}
- class ToFunction a where
- toFunction :: a -> Function
- type FunctionMap = HashMap Identifier Function
Documentation
class HasTemplates hs whereSource
defaultLayout :: Controller hs (Maybe Template)Source
The layout to use by default. Layouts are just templates that embed views. They are rendered with the a global object containing the rendered view in the "yield" field, and the object the view was rendered with in the "page" field. By default, no template is used.
viewDirectory :: Controller hs FilePathSource
The directory to look for views passed to render
. This defaults to
"views", so
render "index.html.tmpl" ...
will look for a view template in "views/index.html.tmpl".
functionMap :: Controller hs FunctionMapSource
A map of pure functions that can be called from within a template. See
FunctionMap
and Function
for details.
getTemplate :: FilePath -> Controller hs TemplateSource
Function to use to get a template. By default, it looks in the
viewDirectory
for the given file name and compiles the file into a
template. This can be overriden to, for example, cache compiled templates
in memory.
render :: ToJSON a => FilePath -> a -> Controller hs ()Source
Renders a view template with the default layout and a global used to evaluate variables in the template.
renderPlain :: ToJSON a => FilePath -> a -> Controller hs ()Source
Same as render
but without a template.
renderLayout :: ToJSON a => FilePath -> FilePath -> a -> Controller hs ()Source
Render a view using the layout named by the first argument.
renderLayout' :: ToJSON a => Template -> FilePath -> a -> Controller hs ()Source
Same as renderLayout
but uses an already compiled layout.
defaultGetTemplate :: HasTemplates hs => FilePath -> Controller hs TemplateSource
defaultRender :: (HasTemplates hs, ToJSON a) => FilePath -> a -> Controller hs ()Source
fromList :: (Eq k, Hashable k) => [(k, v)] -> HashMap k v
O(n*log n) Construct a map with the supplied mappings. If the list contains duplicate mappings, the later mappings take precedence.
newtype Function
A funcation that's callable from inside a template
class ToFunction a where
toFunction :: a -> Function
FromJSON a => ToFunction (a -> Value) | |
(FromJSON a1, FromJSON a2) => ToFunction (a1 -> a2 -> Value) | |
(FromJSON a1, FromJSON a2, FromJSON a3) => ToFunction (a1 -> a2 -> a3 -> Value) | |
(FromJSON a1, FromJSON a2, FromJSON a3, FromJSON a4) => ToFunction (a1 -> a2 -> a3 -> a4 -> Value) | |
(FromJSON a1, FromJSON a2, FromJSON a3, FromJSON a4, FromJSON a5) => ToFunction (a1 -> a2 -> a3 -> a4 -> a5 -> Value) | |
(FromJSON a1, FromJSON a2, FromJSON a3, FromJSON a4, FromJSON a5, FromJSON a6) => ToFunction (a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> Value) | |
(FromJSON a1, FromJSON a2, FromJSON a3, FromJSON a4, FromJSON a5, FromJSON a6, FromJSON a7) => ToFunction (a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> Value) | |
(FromJSON a1, FromJSON a2, FromJSON a3, FromJSON a4, FromJSON a5, FromJSON a6, FromJSON a7, FromJSON a8) => ToFunction (a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> Value) |
type FunctionMap = HashMap Identifier Function