hamlet-0.2.2: Haml-like template files that are compile-time checked

Text.Hamlet

Synopsis

Documentation

xhamlet :: QuasiQuoterSource

Calls hamletWithSettings using XHTML 1.0 Strict settings.

hamletWithSettings :: HamletSettings -> QuasiQuoterSource

A quasi-quoter that converts Hamlet syntax into a function of form:

argument -> Hamlet url m ()

Please see accompanying documentation for a description of Hamlet syntax. You must ensure that the type of m, url and argument all work properly with the functions referred to in the template. Of course, worst case scenario is the compiler will catch your mistakes.

data HamletSettings Source

Settings for parsing of a hamlet document.

Constructors

HamletSettings 

Fields

hamletDoctype :: String

The value to replace a "!!!" with. Do not include the trailing newline.

hamletCloseEmpties :: Bool

True means to close empty tags (eg, img) with a trailing slash, ie XML-style empty tags. False uses HTML-style.

defaultHamletSettings :: HamletSettingsSource

Defaults settings: HTML5 doctype and HTML-style empty tags.

newtype Hamlet url m a Source

Hamlet is a monad that has two features:

  • It passes along a function to convert a URL to a String.
  • It keeps an Iteratee and a seed value so that it can output values. Output is all done through a strict Text value.

The URL to String function makes it very convenient to write templates without knowing the absolute URLs for all referenced resources. For more information on this approach, please see the web-routes package.

For efficiency, the Hamlet monad halts execution as soon as the underlying Iteratee returns a Left value. This is normally what you want; this might cause a problem if you are relying on the side effects of a Hamlet action. However, it is not recommended to rely on side-effects. Though a Hamlet monad may perform IO actions, this should only be used for read-only behavior for efficiency.

Constructors

Hamlet 

Fields

runHamlet :: forall seed. (url -> String) -> seed -> Iteratee Text seed m -> m (Either seed (a, seed))
 

Instances

Monad m => Monad (Hamlet url m) 
Monad m => Functor (Hamlet url m) 
Monad m => Applicative (Hamlet url m) 

data HtmlContent Source

Content for an HTML document. Encoded content should not be entity escaped; Unencoded should be.

Constructors

Encoded Text 
Unencoded Text 

printHamlet :: (url -> String) -> Hamlet url IO () -> IO ()Source

Prints a Hamlet to standard out. Good for debugging.

newtype Enumerator val m Source

Generates a stream of values to be passed to an Iteratee.

Constructors

Enumerator 

Fields

runEnumerator :: forall seed. Iteratee val seed m -> seed -> m (Either seed seed)
 

fromList :: Monad m => [a] -> Enumerator a mSource

Convert a list into an Enumerator.