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

Text.Hamlet

Contents

Synopsis

Basic quasiquoters

xhamlet :: QuasiQuoterSource

Calls hamletWithSettings using XHTML 1.0 Strict settings.

hamletDebug :: QuasiQuoterSource

Calls hamletWithSettings with debugHamletSettings.

Load from external file

xhamletFile :: FilePath -> Q ExpSource

Calls hamletFileWithSettings using XHTML 1.0 Strict settings.

Customized settings

hamletWithSettings :: HamletSettings -> QuasiQuoterSource

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

 (url -> String) -> Html

Please see accompanying documentation for a description of Hamlet syntax.

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.

hamletCloseNewline :: Bool

Should we put a newline after closing a tag? Mostly useful for debug output.

hamletCloseStyle :: String -> CloseStyle

How a tag should be closed. Use this to switch between HTML, XHTML or even XML output.

defaultHamletSettings :: HamletSettingsSource

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

Datatypes

type Html = HtmlM ()

Simplification of the HtmlM datatype.

type Hamlet url = (url -> [(String, String)] -> String) -> HtmlSource

An function generating an Html given a URL-rendering function.

Typeclass

Construction

preEscapedString

Arguments

:: String

String to insert.

-> Html

Resulting HTML fragment.

Create an HTML snippet from a String without escaping

string

Arguments

:: String

String to insert.

-> Html

Resulting HTML fragment.

Create an HTML snippet from a String.

unsafeByteString

Arguments

:: ByteString

Value to insert.

-> Html

Resulting HTML fragment.

Insert a ByteString. This is an unsafe operation:

  • The ByteString could have the wrong encoding.
  • The ByteString might contain illegal HTML characters (no escaping is done).

cdata :: Html -> HtmlSource

Wrap an Html for embedding in an XML file.

Rendering

ByteString

renderHamlet :: (url -> [(String, String)] -> String) -> Hamlet url -> ByteStringSource

Converts a Hamlet to lazy bytestring.

renderHtml

Arguments

:: Html

HTML to render

-> ByteString

Resulting ByteString

Render HTML to a lazy UTF-8 encoded 'L.ByteString.'

Text

renderHamletText :: (url -> [(String, String)] -> String) -> Hamlet url -> TextSource

Runtime Hamlet