hamlet-0.8.2.1: Haml-like template files that are compile-time checkedSource codeContentsIndex
Text.Hamlet
Contents
Basic quasiquoters
Load from external file
Customized settings
Datatypes
Typeclass
Construction
Rendering
ByteString
Text
Runtime Hamlet
Synopsis
hamlet :: QuasiQuoter
xhamlet :: QuasiQuoter
hamletDebug :: QuasiQuoter
hamletFile :: FilePath -> Q Exp
xhamletFile :: FilePath -> Q Exp
hamletFileDebug :: FilePath -> Q Exp
hamletWithSettings :: HamletSettings -> QuasiQuoter
hamletFileWithSettings :: HamletSettings -> FilePath -> Q Exp
data HamletSettings = HamletSettings {
hamletDoctype :: String
hamletCloseNewline :: Bool
hamletCloseStyle :: String -> CloseStyle
}
defaultHamletSettings :: HamletSettings
xhtmlHamletSettings :: HamletSettings
type Html = HtmlM ()
type Hamlet url = (url -> [(Text, Text)] -> Text) -> Html
class Monad (HamletMonad a) => HamletValue a where
data HamletMonad a :: * -> *
type HamletUrl a
toHamletValue :: HamletMonad a () -> a
htmlToHamletMonad :: Html -> HamletMonad a ()
urlToHamletMonad :: HamletUrl a -> [(Text, Text)] -> HamletMonad a ()
fromHamletValue :: a -> HamletMonad a ()
preEscapedString :: String -> Html
preEscapedText :: Text -> Html
preEscapedLazyText :: Text -> Html
string :: String -> Html
unsafeByteString :: ByteString -> Html
cdata :: Html -> Html
toHtml :: ToHtml a => a -> Html
renderHamlet :: (url -> [(Text, Text)] -> Text) -> Hamlet url -> ByteString
renderHtml :: Html -> ByteString
renderHamletText :: (url -> [(Text, Text)] -> Text) -> Hamlet url -> Text
renderHtmlText :: Html -> Text
data HamletRT
data HamletData url
= HDHtml Html
| HDUrl url
| HDUrlParams url [(Text, Text)]
| HDTemplate HamletRT
| HDBool Bool
| HDMaybe (Maybe (HamletMap url))
| HDList [HamletMap url]
data HamletException
= HamletParseException String
| HamletUnsupportedDocException Doc
| HamletRenderException String
parseHamletRT :: Failure HamletException m => HamletSettings -> String -> m HamletRT
renderHamletRT :: Failure HamletException m => HamletRT -> HamletMap url -> (url -> [(Text, Text)] -> Text) -> m Html
Basic quasiquoters
hamlet :: QuasiQuoterSource
Calls hamletWithSettings with defaultHamletSettings.
xhamlet :: QuasiQuoterSource
Calls hamletWithSettings using XHTML 1.0 Strict settings.
hamletDebug :: QuasiQuoterSource
Calls hamletWithSettings with debugHamletSettings.
Load from external file
hamletFile :: FilePath -> Q ExpSource
Calls hamletFileWithSettings with defaultHamletSettings.
xhamletFile :: FilePath -> Q ExpSource
Calls hamletFileWithSettings using XHTML 1.0 Strict settings.
hamletFileDebug :: FilePath -> Q ExpSource
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.

hamletFileWithSettings :: HamletSettings -> FilePath -> Q ExpSource
data HamletSettings Source
Settings for parsing of a hamlet document.
Constructors
HamletSettings
hamletDoctype :: StringThe value to replace a "!!!" with. Do not include the trailing newline.
hamletCloseNewline :: BoolShould we put a newline after closing a tag? Mostly useful for debug output.
hamletCloseStyle :: String -> CloseStyleHow 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.
xhtmlHamletSettings :: HamletSettingsSource
Datatypes
type Html = HtmlM ()Source
Simplification of the HtmlM datatype.
type Hamlet url = (url -> [(Text, Text)] -> Text) -> HtmlSource
An function generating an Html given a URL-rendering function.
Typeclass
class Monad (HamletMonad a) => HamletValue a whereSource
Associated Types
data HamletMonad a :: * -> *Source
type HamletUrl a Source
Methods
toHamletValue :: HamletMonad a () -> aSource
htmlToHamletMonad :: Html -> HamletMonad a ()Source
urlToHamletMonad :: HamletUrl a -> [(Text, Text)] -> HamletMonad a ()Source
fromHamletValue :: a -> HamletMonad a ()Source
show/hide Instances
Construction
preEscapedStringSource
:: StringString to insert.
-> HtmlResulting HTML fragment.
Create an HTML snippet from a String without escaping
preEscapedTextSource
:: TextText to insert
-> HtmlResulting HTML fragment
Render text without escaping.
preEscapedLazyTextSource
:: TextText to insert
-> HtmlResulting HTML fragment
A variant of preEscapedText for lazy Text
stringSource
:: StringString to insert.
-> HtmlResulting HTML fragment.
Create an HTML snippet from a String.
unsafeByteStringSource
:: ByteStringValue to insert.
-> HtmlResulting 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.
toHtml :: ToHtml a => a -> HtmlSource
Convert a value to HTML.
Rendering
ByteString
renderHamlet :: (url -> [(Text, Text)] -> Text) -> Hamlet url -> ByteStringSource
Converts a Hamlet to lazy bytestring.
renderHtmlSource
:: HtmlHTML to render
-> ByteStringResulting ByteString
Render HTML to a lazy UTF-8 encoded 'L.ByteString.'
Text
renderHamletText :: (url -> [(Text, Text)] -> Text) -> Hamlet url -> TextSource
renderHtmlText :: Html -> TextSource
Runtime Hamlet
data HamletRT Source
data HamletData url Source
Constructors
HDHtml Html
HDUrl url
HDUrlParams url [(Text, Text)]
HDTemplate HamletRT
HDBool Bool
HDMaybe (Maybe (HamletMap url))
HDList [HamletMap url]
data HamletException Source
Constructors
HamletParseException String
HamletUnsupportedDocException Doc
HamletRenderException String
show/hide Instances
parseHamletRT :: Failure HamletException m => HamletSettings -> String -> m HamletRTSource
renderHamletRT :: Failure HamletException m => HamletRT -> HamletMap url -> (url -> [(Text, Text)] -> Text) -> m HtmlSource
Produced by Haddock version 2.6.1