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

Safe HaskellNone
LanguageHaskell2010

Snap.Extras.SpliceUtils.Compiled

Synopsis

Documentation

utilSplices :: MonadSnap m => Splices (Splice m) Source

refererCSplice :: MonadSnap m => Splice m Source

paramSplice :: MonadSnap m => Splice m Source

Gets the value of a request parameter. Example use:

name="username"/

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.

-> Splice m 

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.

fancyLoopSplice :: Monad n => Splices (RuntimeSplice n a -> Splice n) -> RuntimeSplice n [a] -> Splice n Source

Sometimes in a loop you don't always want the same behavior for every item. If you have a comma separated list, you usually don't want a comma after the last item. If you have a list surrounded by parentheses, you might not want the parentheses to show up if the list is empty. Dealing with these situations can be a pain with the stock looping splices, so we've provided this helper that solves all of these problems.

This function is similar to manyWithSplices, but it binds three additional splices: "prelude", "interlude", and "postlude". The children of the prelude and postlude splices only show up before the beginning of the list and after the end of the list if the list is non-empty. The children of the interlude splice are used as a separator between each list element. If the list has only one element, then the separator does not appear. These splices have this behavior regardless of where they appear in the parent tag.