snap-extras-0.12.3.0: A collection of useful helpers and utilities for Snap web applications.

Safe HaskellNone
LanguageHaskell2010

Snap.Extras.SpliceUtils.Interpreted

Synopsis

Documentation

paramSplice :: MonadSnap m => Splice m Source #

Gets the value of a request parameter. Example use:

name="username"/

utilSplices :: Splices (SnapletISplice b) Source #

A list of splices offered in this module

selectSplice Source #

Arguments

:: Monad m 
=> Text

A name for the select element

-> Text

An id for the select element

-> [(Text, Text)]

value, shown text pairs

-> Maybe Text

Default value

-> Splice m 

Splice helper for when you're rendering a select element

runTextAreas :: Monad m => HeistState m -> HeistState m Source #

Assume text area contains the name of a splice as Text.

This is helpful when you pass a default value to digestive-functors by putting the name of a splice as the value of a textarea tag.

heistLocal runTextAreas $ render "joo/index"

scriptsSplice Source #

Arguments

:: MonadIO m 
=> FilePath

Path to the directory on disk holding the javascript files.

-> String

A prefix to add to the src attribute of each script tag.

-> m [Node] 

Searches a directory on disk and all its subdirectories for all files with names that don't begin with an underscore and end with a .js extension. It then returns script tags for each of these files.

You can use this function to create a splice:

("staticscripts", scriptsSplice "static/js" "/")

Then when you use the <staticscripts/> tag in your templates, it will automatically include all the javascript code in the static/js directory.

ifFlagSplice :: SnapletISplice b Source #

Check to see if the boolean flag named by the "ref" attribute is present and set to true in snaplet user config file. If so, run what's inside this splice, if not, simply omit that part.

Example:

<flag ref="beta-functions-enabled">
stuff...
</flag>

This will look for an entry inside your .cfg file:

beta-functions-enabled = true