snap-0.11.3: Top-level package for the Snap Web Framework

Safe HaskellNone

Snap.Snaplet.HeistNoClass

Description

This module implements the Heist snaplet without using type classes. It is provided mainly as an example of how snaplets can be written with and without a type class for convenience.

Synopsis

Documentation

data Heist b Source

The state for the Heist snaplet. To use the Heist snaplet in your app include this in your application state and use heistInit to initialize it. The type parameter b will typically be the base state type for your application.

heistInitSource

Arguments

:: FilePath

Path to templates

-> SnapletInit b (Heist b) 

The Initializer for Heist. This function is a convenience wrapper around heistInit' that uses defaultHeistState and sets up routes for all the templates.

heistInit'Source

Arguments

:: FilePath

Path to templates

-> HeistConfig (Handler b b)

Initial HeistConfig

-> SnapletInit b (Heist b) 

A lower level Initializer for Heist. This initializer requires you to specify the initial HeistConfig. It also does not add any routes for templates, allowing you complete control over which templates get routed.

clearHeistCache :: Heist b -> IO ()Source

Clears data stored by the cache tag. The cache tag automatically reloads its data when the specified TTL expires, but sometimes you may want to trigger a manual reload. This function lets you do that.

addTemplatesSource

Arguments

:: Snaplet (Heist b) 
-> ByteString

The url prefix for the template routes

-> Initializer b (Heist b) () 

Adds templates to the Heist HeistConfig. Other snaplets should use this function to add their own templates. The templates are automatically read from the templates directory in the current snaplet's filesystem root.

addTemplatesAtSource

Arguments

:: Snaplet (Heist b) 
-> ByteString

URL prefix for template routes

-> FilePath

Path to templates

-> Initializer b (Heist b) () 

Adds templates to the Heist HeistConfig, and lets you specify where they are found in the filesystem. Note that the path to the template directory is an absolute path. This allows you more flexibility in where your templates are located, but means that you have to explicitly call getSnapletFilePath if you want your snaplet to use templates within its normal directory structure.

addConfig :: Snaplet (Heist b) -> HeistConfig (Handler b b) -> Initializer b v ()Source

Adds more HeistConfig data using mappend with whatever is currently there. This is the preferred method for adding all four kinds of splices as well as new templates.

cRenderSource

Arguments

:: ByteString

Name of the template

-> Handler b (Heist b) () 

cRenderAsSource

Arguments

:: ByteString

Content type

-> ByteString

Name of the template

-> Handler b (Heist b) () 

renderSource

Arguments

:: ByteString

Name of the template

-> Handler b (Heist b) () 

renderAsSource

Arguments

:: ByteString

Content type

-> ByteString

Name of the template

-> Handler b (Heist b) () 

heistLocal :: SnapletLens b (Heist b) -> (HeistState (Handler b b) -> HeistState (Handler b b)) -> Handler b v a -> Handler b v aSource

type SnapletHeist b m a = HeistT (Handler b b) m aSource