heist-0.14.1.1: An Haskell template system supporting both HTML5 and XML.

Safe Haskell | None
Language | Haskell98

Heist.SpliceAPI

Description

Deprecated: Use Data.Map.Syntax from the map-syntax package instead

An API implementing a convenient syntax for defining and manipulating splices. This module was born from the observation that a list of tuples is semantically ambiguous about how duplicate keys should be handled. Additionally, the syntax is inherently rather cumbersome and difficult to work with. This API takes advantage of do notation to provide a very light syntax for defining splices while at the same time eliminating the semantic ambiguity of alists.

Here's how you can define splices:

    mySplices :: Splices Text
    mySplices = do
      "firstName" ## "John"
      "lastName"  ## "Smith"

Synopsis

- type SplicesM s a = MapSyntaxM Text s a
- type Splices s = MapSyntax Text s
- noSplices :: Splices s
- mapS :: (a -> b) -> Splices a -> Splices b
- applyS :: a -> Splices (a -> b) -> Splices b
- ($$) :: Splices (a -> b) -> a -> Splices b
- mapNames :: (Text -> Text) -> Splices a -> Splices a
- prefixSplices :: Text -> Text -> Splices a -> Splices a
- namespaceSplices :: Text -> Splices a -> Splices a
- module Data.Map.Syntax

# Documentation

type SplicesM s a = MapSyntaxM Text s a Source

type Splices s = MapSyntax Text s Source

Convenient type alies for splices.

noSplices :: Splices s Source

mapS :: (a -> b) -> Splices a -> Splices b Source

Maps a function over all the splices.

applyS :: a -> Splices (a -> b) -> Splices b Source

Applies an argument to a splice function.

($$) :: Splices (a -> b) -> a -> Splices b infixr 0 Source

Infix operator for `flip applyS`

mapNames :: (Text -> Text) -> Splices a -> Splices a Source

Maps a function over all the splice names.

prefixSplices :: Text -> Text -> Splices a -> Splices a Source

Adds a prefix to the tag names for a list of splices. If the existing tag name is empty, then the new tag name is just the prefix. Otherwise the new tag name is the prefix followed by the separator followed by the existing name.

namespaceSplices :: Text -> Splices a -> Splices a Source

`prefixSplices` specialized to use a colon as separator in the style of XML namespaces.

module Data.Map.Syntax