lucid-svg-0.7.1: DSL for SVG using lucid for HTML

Copyright(c) 2015 Jeffrey Rosenbluth
LicenseBSD-style (see LICENSE)
Maintainerjeffrey.rosenbluth@gmail.com
Safe HaskellNone
LanguageHaskell2010

Lucid.Svg

Contents

Description

DSL for creating SVG.

Synopsis

Intro

SVG elements and attributes in Lucid-Svg are written with a postfix ‘_’. Some examples:

path_, circle_, color_, scale_

Note: If you're testing in the REPL you need to add a type annotation to indicate that you want SVG. In normal code your top-level declaration signatures handle that.

Plain text is written using the OverloadedStrings and ExtendedDefaultRules extensions, and is automatically escaped:

As in Lucid, elements nest by function application:

>>> g_ (text_ "Hello SVG") :: Svg ()
<g><text>Hello SVG</text></g>

and elements are juxtaposed via monoidal append or monadic sequencing:

>>> text_ "Hello" <> text_ "SVG" :: Svg ()
<text>Hello</text><text>SVG</text>
>>> do text_ "Hello"; text_ "SVG" :: Svg ()
<text>Hello</text><text>SVG</text>

Attributes are set by providing an argument list. In contrast to HTML many SVG elements have no content, only attributes.

>>> rect_ [width_ "100%", height_ "100%", fill_ "red"] :: Svg ()
<rect height="100%" width="100%" fill="red"></rect>

Attributes and elements that share the same name are not conflicting unless they appear on the list in the note below:

>>> mask_ [mask_ "attribute"] "element" :: Svg ()
<mask mask="attribute">element</mask>

Note: The following element and attribute names overlap and cannot be handled polymorphically since doing so would create conflicting functional dependencies. The unqualifed name refers to the element. We qualify the attribute name as A. For example, path_ and path_.

colorProfile_, cursor_, filter_, path_, and style_

Path data can be constructed using the functions in Path and combined monoidally:

path_ (
  [ d_ (mA 10 80 <> qA 52.5 10 95 80 <> tA 180 80 <> z)
  , stroke_ "blue"
  , fill_ "orange"
  ])
<path d="M 10,80 Q 52.5,10 95,80 T 180,80 Z" stroke="blue" fill="orange"></path>

A slightly longer example:

import Lucid.Svg

svg :: Svg () -> Svg ()
svg content = do
  doctype_
  with (svg11_ content) [version_ "1.1", width_ "300" , height_ "200"]

contents :: Svg ()
contents = do
  rect_ [width_ "100%", height_ "100%", fill_ "red"]
  circle_ [cx_ "150", cy_ "100", r_ "80", fill_ "green"]
  text_ [x_ "150", y_ "125", fontSize_ "60", textAnchor_ "middle", fill_ "white"] "SVG"


main :: IO ()
main = do
  print $ svg contents

Rendering

Re-exports

accent_height_ :: Text -> Attribute #

The accentHeight attribute.

accumulate_ :: Text -> Attribute #

The accumulate attribute.

additive_ :: Text -> Attribute #

The additive attribute.

alignment_baseline_ :: Text -> Attribute #

The alignmentBaseline attribute.

alphabetic_ :: Text -> Attribute #

The alphabetic attribute.

amplitude_ :: Text -> Attribute #

The amplitude attribute.

arabic_form_ :: Text -> Attribute #

The arabicForm attribute.

ascent_ :: Text -> Attribute #

The ascent attribute.

attributeName_ :: Text -> Attribute #

The attributename attribute.

attributeType_ :: Text -> Attribute #

The attributetype attribute.

azimuth_ :: Text -> Attribute #

The azimuth attribute.

baseFrequency_ :: Text -> Attribute #

The basefrequency attribute.

baseprofile_ :: Text -> Attribute #

The baseprofile attribute.

baseline_shift_ :: Text -> Attribute #

The baselineShift attribute.

bbox_ :: Text -> Attribute #

The bbox attribute.

begin_ :: Text -> Attribute #

The begin attribute.

bias_ :: Text -> Attribute #

The bias attribute.

by_ :: Text -> Attribute #

The by attribute.

calcMode_ :: Text -> Attribute #

The calcmode attribute.

cap_height_ :: Text -> Attribute #

The capHeight attribute.

class_ :: Text -> Attribute #

The class attribute.

clip_ :: Text -> Attribute #

The clip attribute.

clip_path_ :: Text -> Attribute #

The clip-path attribute.

clip_rule_ :: Text -> Attribute #

The clipRule attribute.

clipPathUnits_ :: Text -> Attribute #

The clippathunits attribute.

color_ :: Text -> Attribute #

The color attribute.

color_interpolation_ :: Text -> Attribute #

The colorInterpolation attribute.

color_interpolation_filters_ :: Text -> Attribute #

The colorInterpolationFilters attribute.

color_profile_ :: Text -> Attribute #

The colorProfile attribute.

color_rendering_ :: Text -> Attribute #

The colorRendering attribute.

contentScriptType_ :: Text -> Attribute #

The contentscripttype attribute.

contentStyleType_ :: Text -> Attribute #

The contentstyletype attribute.

cx_ :: Text -> Attribute #

The cx attribute.

cy_ :: Text -> Attribute #

The cy attribute.

d_ :: Text -> Attribute #

The d attribute.

descent_ :: Text -> Attribute #

The descent attribute.

diffuseConstant_ :: Text -> Attribute #

The diffuseconstant attribute.

direction_ :: Text -> Attribute #

The direction attribute.

display_ :: Text -> Attribute #

The display attribute.

divisor_ :: Text -> Attribute #

The divisor attribute.

dominant_baseline_ :: Text -> Attribute #

The dominantBaseline attribute.

dur_ :: Text -> Attribute #

The dur attribute.

dx_ :: Text -> Attribute #

The dx attribute.

dy_ :: Text -> Attribute #

The dy attribute.

edgeMode_ :: Text -> Attribute #

The edgemode attribute.

elevation_ :: Text -> Attribute #

The elevation attribute.

enable_background_ :: Text -> Attribute #

The enableBackground attribute.

end_ :: Text -> Attribute #

The end attribute.

exponent_ :: Text -> Attribute #

The exponent attribute.

externalResourcesRequired_ :: Text -> Attribute #

The externalresourcesrequired attribute.

fill_ :: Text -> Attribute #

The fill attribute.

fill_opacity_ :: Text -> Attribute #

The fillOpacity attribute.

fill_rule_ :: Text -> Attribute #

The fillRule attribute.

filterRes_ :: Text -> Attribute #

The filterres attribute.

filterUnits_ :: Text -> Attribute #

The filterunits attribute.

flood_color_ :: Text -> Attribute #

The floodColor attribute.

flood_opacity_ :: Text -> Attribute #

The floodOpacity attribute.

font_family_ :: Text -> Attribute #

The fontFamily attribute.

font_size_ :: Text -> Attribute #

The fontSize attribute.

font_size_adjust_ :: Text -> Attribute #

The fontSizeAdjust attribute.

font_stretch_ :: Text -> Attribute #

The fontStretch attribute.

font_style_ :: Text -> Attribute #

The fontStyle attribute.

font_variant_ :: Text -> Attribute #

The fontVariant attribute.

font_weight_ :: Text -> Attribute #

The fontWeight attribute.

format_ :: Text -> Attribute #

The format attribute.

from_ :: Text -> Attribute #

The from attribute.

fx_ :: Text -> Attribute #

The fx attribute.

fy_ :: Text -> Attribute #

The fy attribute.

g1_ :: Text -> Attribute #

The g1 attribute.

g2_ :: Text -> Attribute #

The g2 attribute.

glyph_name_ :: Text -> Attribute #

The glyphName attribute.

glyph_orientation_horizontal_ :: Text -> Attribute #

The glyphOrientationHorizontal attribute.

glyph_orientation_vertical_ :: Text -> Attribute #

The glyphOrientationVertical attribute.

gradientTransform_ :: Text -> Attribute #

The -- | The gradienttransform@ attribute.

gradientUnits_ :: Text -> Attribute #

The gradientunits attribute.

hanging_ :: Text -> Attribute #

The hanging attribute.

height_ :: Text -> Attribute #

The height attribute.

horiz_adv_x_ :: Text -> Attribute #

The horizAdvX attribute.

horiz_origin_x_ :: Text -> Attribute #

The horizOriginX attribute.

horiz_origin_y_ :: Text -> Attribute #

The horizOriginY attribute.

id_ :: Text -> Attribute #

The id attribute.

ideographic_ :: Text -> Attribute #

The ideographic attribute.

image_rendering_ :: Text -> Attribute #

The imageRendering attribute.

in_ :: Text -> Attribute #

The in attribute.

in2_ :: Text -> Attribute #

The in2 attribute.

intercept_ :: Text -> Attribute #

The intercept attribute.

k_ :: Text -> Attribute #

The k attribute.

k1_ :: Text -> Attribute #

The k1 attribute.

k2_ :: Text -> Attribute #

The k2 attribute.

k3_ :: Text -> Attribute #

The k3 attribute.

k4_ :: Text -> Attribute #

The k4 attribute.

kernelMatrix_ :: Text -> Attribute #

The kernelmatrix attribute.

kernelUnitLength_ :: Text -> Attribute #

The kernelunitlength attribute.

kerning_ :: Text -> Attribute #

The kerning attribute.

keyPoints_ :: Text -> Attribute #

The keypoints attribute.

keySplines_ :: Text -> Attribute #

The keysplines attribute.

keyTimes_ :: Text -> Attribute #

The keytimes attribute.

lang_ :: Text -> Attribute #

The lang attribute.

lengthAdjust_ :: Text -> Attribute #

The lengthadjust attribute.

letter_spacing_ :: Text -> Attribute #

The letterSpacing attribute.

lighting_color_ :: Text -> Attribute #

The lightingColor attribute.

limitingConeAngle_ :: Text -> Attribute #

The limitingconeangle attribute.

local_ :: Text -> Attribute #

The local attribute.

marker_end_ :: Text -> Attribute #

The markerEnd attribute.

marker_mid_ :: Text -> Attribute #

The markerMid attribute.

marker_start_ :: Text -> Attribute #

The markerStart attribute.

markerHeight_ :: Text -> Attribute #

The markerheight attribute.

markerUnits_ :: Text -> Attribute #

The markerunits attribute.

markerWidth_ :: Text -> Attribute #

The markerwidth attribute.

maskContentUnits_ :: Text -> Attribute #

The maskcontentunits attribute.

maskUnits_ :: Text -> Attribute #

The maskunits attribute.

mathematical_ :: Text -> Attribute #

The mathematical attribute.

max_ :: Text -> Attribute #

The max attribute.

media_ :: Text -> Attribute #

The media attribute.

method_ :: Text -> Attribute #

The method attribute.

min_ :: Text -> Attribute #

The min attribute.

mode_ :: Text -> Attribute #

The mode attribute.

name_ :: Text -> Attribute #

The name attribute.

numOctaves_ :: Text -> Attribute #

The numoctaves attribute.

offset_ :: Text -> Attribute #

The offset attribute.

onabort_ :: Text -> Attribute #

The onabort attribute.

onactivate_ :: Text -> Attribute #

The onactivate attribute.

onbegin_ :: Text -> Attribute #

The onbegin attribute.

onclick_ :: Text -> Attribute #

The onclick attribute.

onend_ :: Text -> Attribute #

The onend attribute.

onerror_ :: Text -> Attribute #

The onerror attribute.

onfocusin_ :: Text -> Attribute #

The onfocusin attribute.

onfocusout_ :: Text -> Attribute #

The onfocusout attribute.

onload_ :: Text -> Attribute #

The onload attribute.

onmousedown_ :: Text -> Attribute #

The onmousedown attribute.

onmousemove_ :: Text -> Attribute #

The onmousemove attribute.

onmouseout_ :: Text -> Attribute #

The onmouseout attribute.

onmouseover_ :: Text -> Attribute #

The onmouseover attribute.

onmouseup_ :: Text -> Attribute #

The onmouseup attribute.

onrepeat_ :: Text -> Attribute #

The onrepeat attribute.

onresize_ :: Text -> Attribute #

The onresize attribute.

onscroll_ :: Text -> Attribute #

The onscroll attribute.

onunload_ :: Text -> Attribute #

The onunload attribute.

onzoom_ :: Text -> Attribute #

The onzoom attribute.

opacity_ :: Text -> Attribute #

The opacity attribute.

operator_ :: Text -> Attribute #

The operator attribute.

order_ :: Text -> Attribute #

The order attribute.

orient_ :: Text -> Attribute #

The orient attribute.

orientation_ :: Text -> Attribute #

The orientation attribute.

origin_ :: Text -> Attribute #

The origin attribute.

overflow_ :: Text -> Attribute #

The overflow attribute.

overline_position_ :: Text -> Attribute #

The overlinePosition attribute.

overline_thickness_ :: Text -> Attribute #

The overlineThickness attribute.

panose_1_ :: Text -> Attribute #

The panose1 attribute.

paint_order_ :: Text -> Attribute #

The paint-order attribute.

pathLength_ :: Text -> Attribute #

The pathlength attribute.

patternContentUnits_ :: Text -> Attribute #

The patterncontentunits attribute.

patternTransform_ :: Text -> Attribute #

The patterntransform attribute.

patternUnits_ :: Text -> Attribute #

The patternunits attribute.

pointer_events_ :: Text -> Attribute #

The pointerEvents attribute.

points_ :: Text -> Attribute #

The points attribute.

pointsAtX_ :: Text -> Attribute #

The pointsatx attribute.

pointsAtY_ :: Text -> Attribute #

The pointsaty attribute.

pointsAtZ_ :: Text -> Attribute #

The pointsatz attribute.

preserveAlpha_ :: Text -> Attribute #

The preservealpha attribute.

preserveAspectRatio_ :: Text -> Attribute #

The preserveaspectratio attribute.

primitiveUnits_ :: Text -> Attribute #

The primitiveunits attribute.

r_ :: Text -> Attribute #

The r attribute.

radius_ :: Text -> Attribute #

The radius attribute.

refX_ :: Text -> Attribute #

The refx attribute.

refY_ :: Text -> Attribute #

The refy attribute.

rendering_intent_ :: Text -> Attribute #

The renderingIntent attribute.

repeatCount_ :: Text -> Attribute #

The repeatcount attribute.

repeatDur_ :: Text -> Attribute #

The repeatdur attribute.

requiredExtensions_ :: Text -> Attribute #

The requiredextensions attribute.

requiredFeatures_ :: Text -> Attribute #

The requiredfeatures attribute.

restart_ :: Text -> Attribute #

The restart attribute.

result_ :: Text -> Attribute #

The result attribute.

rotate_ :: Text -> Attribute #

The rotate attribute.

rx_ :: Text -> Attribute #

The rx attribute.

ry_ :: Text -> Attribute #

The ry attribute.

scale_ :: Text -> Attribute #

The scale attribute.

seed_ :: Text -> Attribute #

The seed attribute.

shape_rendering_ :: Text -> Attribute #

The shapeRendering attribute.

slope_ :: Text -> Attribute #

The slope attribute.

spacing_ :: Text -> Attribute #

The spacing attribute.

specularConstant_ :: Text -> Attribute #

The specularconstant attribute.

specularExponent_ :: Text -> Attribute #

The specularexponent attribute.

spreadMethod_ :: Text -> Attribute #

The spreadmethod attribute.

startOffset_ :: Text -> Attribute #

The startoffset attribute.

stdDeviation_ :: Text -> Attribute #

The stddeviation attribute.

stemh_ :: Text -> Attribute #

The stemh attribute.

stemv_ :: Text -> Attribute #

The stemv attribute.

stitchTiles_ :: Text -> Attribute #

The stitchtiles attribute.

stop_color_ :: Text -> Attribute #

The stopColor attribute.

stop_opacity_ :: Text -> Attribute #

The stopOpacity attribute.

strikethrough_position_ :: Text -> Attribute #

The strikethroughPosition attribute.

strikethrough_thickness_ :: Text -> Attribute #

The strikethroughThickness attribute.

string_ :: Text -> Attribute #

The string attribute.

stroke_ :: Text -> Attribute #

The stroke attribute.

stroke_dasharray_ :: Text -> Attribute #

The strokeDasharray attribute.

stroke_dashoffset_ :: Text -> Attribute #

The strokeDashoffset attribute.

stroke_linecap_ :: Text -> Attribute #

The strokeLinecap attribute.

stroke_linejoin_ :: Text -> Attribute #

The strokeLinejoin attribute.

stroke_miterlimit_ :: Text -> Attribute #

The strokeMiterlimit attribute.

stroke_opacity_ :: Text -> Attribute #

The strokeOpacity attribute.

stroke_width_ :: Text -> Attribute #

The strokeWidth attribute.

surfaceScale_ :: Text -> Attribute #

The surfacescale attribute.

systemLanguage_ :: Text -> Attribute #

The systemlanguage attribute.

tableValues_ :: Text -> Attribute #

The tablevalues attribute.

target_ :: Text -> Attribute #

The target attribute.

targetX_ :: Text -> Attribute #

The targetx attribute.

targetY_ :: Text -> Attribute #

The targety attribute.

text_anchor_ :: Text -> Attribute #

The textAnchor attribute.

text_decoration_ :: Text -> Attribute #

The textDecoration attribute.

text_rendering_ :: Text -> Attribute #

The textRendering attribute.

textLength_ :: Text -> Attribute #

The textlength attribute.

to_ :: Text -> Attribute #

The to attribute.

transform_ :: Text -> Attribute #

The transform attribute.

type_ :: Text -> Attribute #

The type attribute.

u1_ :: Text -> Attribute #

The u1 attribute.

u2_ :: Text -> Attribute #

The u2 attribute.

underline_position_ :: Text -> Attribute #

The underlinePosition attribute.

underline_thickness_ :: Text -> Attribute #

The underlineThickness attribute.

unicode_ :: Text -> Attribute #

The unicode attribute.

unicode_bidi_ :: Text -> Attribute #

The unicodeBidi attribute.

unicode_range_ :: Text -> Attribute #

The unicodeRange attribute.

units_per_em_ :: Text -> Attribute #

The unitsPerEm attribute.

v_alphabetic_ :: Text -> Attribute #

The vAlphabetic attribute.

v_hanging_ :: Text -> Attribute #

The vHanging attribute.

v_ideographic_ :: Text -> Attribute #

The vIdeographic attribute.

v_mathematical_ :: Text -> Attribute #

The vMathematical attribute.

values_ :: Text -> Attribute #

The values attribute.

version_ :: Text -> Attribute #

The version attribute.

vert_adv_y_ :: Text -> Attribute #

The vertAdvY attribute.

vert_origin_x_ :: Text -> Attribute #

The vertOriginX attribute.

vert_origin_y_ :: Text -> Attribute #

The vertOriginY attribute.

viewBox_ :: Text -> Attribute #

The viewbox attribute.

viewTarget_ :: Text -> Attribute #

The viewtarget attribute.

visibility_ :: Text -> Attribute #

The visibility attribute.

width_ :: Text -> Attribute #

The width attribute.

widths_ :: Text -> Attribute #

The widths attribute.

word_spacing_ :: Text -> Attribute #

The wordSpacing attribute.

writing_mode_ :: Text -> Attribute #

The writingMode attribute.

x_ :: Text -> Attribute #

The x attribute.

x_height_ :: Text -> Attribute #

The xHeight attribute.

x1_ :: Text -> Attribute #

The x1 attribute.

x2_ :: Text -> Attribute #

The x2 attribute.

xChannelSelector_ :: Text -> Attribute #

The xchannelselector attribute.

xlinkActuate_ :: Text -> Attribute #

The xlinkActuate attribute.

xlinkArcrole_ :: Text -> Attribute #

The xlinkArcrole attribute.

xlinkHref_ :: Text -> Attribute #

The xlinkHref attribute.

xlinkRole_ :: Text -> Attribute #

The xlinkRole attribute.

xlinkShow_ :: Text -> Attribute #

The xlinkShow attribute.

xlinkTitle_ :: Text -> Attribute #

The xlinkTitle attribute.

xlinkType_ :: Text -> Attribute #

The xlinkType attribute.

xmlBase_ :: Text -> Attribute #

The xmlBase attribute.

xmlLang_ :: Text -> Attribute #

The xmlLang attribute.

xmlSpace_ :: Text -> Attribute #

The xmlSpace attribute.

y_ :: Text -> Attribute #

The y attribute.

y1_ :: Text -> Attribute #

The y1 attribute.

y2_ :: Text -> Attribute #

The y2 attribute.

yChannelselector_ :: Text -> Attribute #

The ychannelselector attribute.

z_ :: Text -> Attribute #

The z attribute.

zoomAndPan_ :: Text -> Attribute #

The zoomandpan attribute.

From Lucid.Base

renderText :: Html a -> Text #

Render the HTML to a lazy Text.

This is a convenience function defined in terms of execHtmlT, runIdentity and toLazyByteString, and decodeUtf8. Check the source if you're interested in the lower-level behaviour.

renderBS :: Html a -> ByteString #

Render the HTML to a lazy ByteString.

This is a convenience function defined in terms of execHtmlT, runIdentity and toLazyByteString. Check the source if you're interested in the lower-level behaviour.

renderTextT :: Monad m => HtmlT m a -> m Text #

Render the HTML to a lazy Text, but in a monad.

This is a convenience function defined in terms of execHtmlT and toLazyByteString, and decodeUtf8. Check the source if you're interested in the lower-level behaviour.

renderBST :: Monad m => HtmlT m a -> m ByteString #

Render the HTML to a lazy ByteString, but in a monad.

This is a convenience function defined in terms of execHtmlT and toLazyByteString. Check the source if you're interested in the lower-level behaviour.

renderToFile :: FilePath -> Html a -> IO () #

Render the HTML to a lazy ByteString.

This is a convenience function defined in terms of execHtmlT, runIdentity and toLazyByteString. Check the source if you're interested in the lower-level behaviour.

Running

execHtmlT #

Arguments

:: Monad m 
=> HtmlT m a

The HTML to generate.

-> m Builder

The a is discarded.

Build the HTML. Analogous to execState.

You might want to use this is if you want to do something with the raw Builder. Otherwise for simple cases you can just use renderText or renderBS.

evalHtmlT #

Arguments

:: Monad m 
=> HtmlT m a

HTML monad to evaluate.

-> m a

Ignore the HTML output and just return the value.

Evaluate the HTML to its return value. Analogous to evalState.

Use this if you want to ignore the HTML output of an action completely and just get the result.

For using with the Html type, you'll need runIdentity e.g.

>>> runIdentity (evalHtmlT (p_ "Hello!"))
()

runHtmlT :: HtmlT m a -> m (HashMap Text Text -> Builder, a) #

This is the low-level way to run the HTML transformer, finally returning an element builder and a value. You can pass mempty for this argument for a top-level call. See evalHtmlT and execHtmlT for easier to use functions.

Types

data Attribute #

A simple attribute. Don't use the constructor, use makeAttribute.

Constructors

Attribute !Text !Text 
Instances
Eq Attribute 
Instance details

Defined in Lucid.Base

Show Attribute 
Instance details

Defined in Lucid.Base

Hashable Attribute 
Instance details

Defined in Lucid.Base

Term Text Attribute

Some terms (like style_, title_) can be used for attributes as well as elements.

Instance details

Defined in Lucid.Base

Methods

term :: Text -> Text -> Attribute #

termWith :: Text -> [Attribute] -> Text -> Attribute #

TermRaw Text Attribute

Some termRaws (like style_, title_) can be used for attributes as well as elements.

Instance details

Defined in Lucid.Base

(Applicative m, f ~ HtmlT m a) => Term [Attribute] (f -> HtmlT m a)

Given attributes, expect more child input.

Instance details

Defined in Lucid.Base

Methods

term :: Text -> [Attribute] -> f -> HtmlT m a #

termWith :: Text -> [Attribute] -> [Attribute] -> f -> HtmlT m a #

(Monad m, ToHtml f, a ~ ()) => TermRaw [Attribute] (f -> HtmlT m a)

Given attributes, expect more child input.

Instance details

Defined in Lucid.Base

Methods

termRaw :: Text -> [Attribute] -> f -> HtmlT m a #

termRawWith :: Text -> [Attribute] -> [Attribute] -> f -> HtmlT m a #

Classes

class Term arg result | result -> arg where #

Used to construct HTML terms.

Simplest use: p_ = term "p" yields p_.

Very overloaded for three cases:

  • The first case is the basic arg of [(Text,Text)] which will return a function that wants children.
  • The second is an arg which is HtmlT m (), in which case the term accepts no attributes and just the children are used for the element.
  • Finally, this is also used for overloaded attributes, like style_ or title_. If a return type of (Text,Text) is inferred then an attribute will be made.

The instances look intimidating but actually the constraints make it very general so that type inference works well even in the presence of things like OverloadedLists and such.

Minimal complete definition

termWith

Methods

term #

Arguments

:: Text

Name of the element or attribute.

-> arg

Either an attribute list or children.

-> result

Result: either an element or an attribute.

Used for constructing elements e.g. term "p" yields p_.

termWith #

Arguments

:: Text

Name.

-> [Attribute]

Attribute transformer.

-> arg

Some argument.

-> result

Result: either an element or an attribute.

Use this if you want to make an element which inserts some pre-prepared attributes into the element.

Instances
Term Text Attribute

Some terms (like style_, title_) can be used for attributes as well as elements.

Instance details

Defined in Lucid.Base

Methods

term :: Text -> Text -> Attribute #

termWith :: Text -> [Attribute] -> Text -> Attribute #

(Applicative m, f ~ HtmlT m a) => Term [Attribute] (f -> HtmlT m a)

Given attributes, expect more child input.

Instance details

Defined in Lucid.Base

Methods

term :: Text -> [Attribute] -> f -> HtmlT m a #

termWith :: Text -> [Attribute] -> [Attribute] -> f -> HtmlT m a #

Applicative m => Term (HtmlT m a) (HtmlT m a)

Given children immediately, just use that and expect no attributes.

Instance details

Defined in Lucid.Base

Methods

term :: Text -> HtmlT m a -> HtmlT m a #

termWith :: Text -> [Attribute] -> HtmlT m a -> HtmlT m a #

class ToHtml a where #

Can be converted to HTML.

Methods

toHtml :: Monad m => a -> HtmlT m () #

Convert to HTML, doing HTML escaping.

toHtmlRaw :: Monad m => a -> HtmlT m () #

Convert to HTML without any escaping.

Instances
ToHtml String 
Instance details

Defined in Lucid.Base

Methods

toHtml :: Monad m => String -> HtmlT m () #

toHtmlRaw :: Monad m => String -> HtmlT m () #

ToHtml ByteString

This instance requires the ByteString to contain UTF-8 encoded text, for the toHtml method. The toHtmlRaw method doesn't care, but the overall HTML rendering methods in this module assume UTF-8.

Since: lucid-2.9.5

Instance details

Defined in Lucid.Base

Methods

toHtml :: Monad m => ByteString -> HtmlT m () #

toHtmlRaw :: Monad m => ByteString -> HtmlT m () #

ToHtml ByteString

This instance requires the ByteString to contain UTF-8 encoded text, for the toHtml method. The toHtmlRaw method doesn't care, but the overall HTML rendering methods in this module assume UTF-8.

Since: lucid-2.9.5

Instance details

Defined in Lucid.Base

Methods

toHtml :: Monad m => ByteString -> HtmlT m () #

toHtmlRaw :: Monad m => ByteString -> HtmlT m () #

ToHtml Text 
Instance details

Defined in Lucid.Base

Methods

toHtml :: Monad m => Text -> HtmlT m () #

toHtmlRaw :: Monad m => Text -> HtmlT m () #

ToHtml Text 
Instance details

Defined in Lucid.Base

Methods

toHtml :: Monad m => Text -> HtmlT m () #

toHtmlRaw :: Monad m => Text -> HtmlT m () #

(a ~ (), m ~ Identity) => ToHtml (HtmlT m a)

Since: lucid-2.9.8

Instance details

Defined in Lucid.Base

Methods

toHtml :: Monad m0 => HtmlT m a -> HtmlT m0 () #

toHtmlRaw :: Monad m0 => HtmlT m a -> HtmlT m0 () #

class With a where #

With an element use these attributes. An overloaded way of adding attributes either to an element accepting attributes-and-children or one that just accepts attributes. See the two instances.

Methods

with #

Arguments

:: a

Some element, either Html a or Html a -> Html a.

-> [Attribute] 
-> a 

With the given element(s), use the given attributes.

Instances
Functor m => With (HtmlT m a -> HtmlT m a)

For the contentful elements: div_

Instance details

Defined in Lucid.Base

Methods

with :: (HtmlT m a -> HtmlT m a) -> [Attribute] -> HtmlT m a -> HtmlT m a #

Functor m => With (HtmlT m a)

For the contentless elements: br_

Instance details

Defined in Lucid.Base

Methods

with :: HtmlT m a -> [Attribute] -> HtmlT m a #