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 Source #

The accentHeight attribute.

accumulate_ :: Text -> Attribute Source #

The accumulate attribute.

additive_ :: Text -> Attribute Source #

The additive attribute.

alignment_baseline_ :: Text -> Attribute Source #

The alignmentBaseline attribute.

alphabetic_ :: Text -> Attribute Source #

The alphabetic attribute.

amplitude_ :: Text -> Attribute Source #

The amplitude attribute.

arabic_form_ :: Text -> Attribute Source #

The arabicForm attribute.

ascent_ :: Text -> Attribute Source #

The ascent attribute.

attributeName_ :: Text -> Attribute Source #

The attributename attribute.

attributeType_ :: Text -> Attribute Source #

The attributetype attribute.

azimuth_ :: Text -> Attribute Source #

The azimuth attribute.

baseFrequency_ :: Text -> Attribute Source #

The basefrequency attribute.

baseprofile_ :: Text -> Attribute Source #

The baseprofile attribute.

baseline_shift_ :: Text -> Attribute Source #

The baselineShift attribute.

bbox_ :: Text -> Attribute Source #

The bbox attribute.

begin_ :: Text -> Attribute Source #

The begin attribute.

bias_ :: Text -> Attribute Source #

The bias attribute.

by_ :: Text -> Attribute Source #

The by attribute.

calcMode_ :: Text -> Attribute Source #

The calcmode attribute.

cap_height_ :: Text -> Attribute Source #

The capHeight attribute.

class_ :: Text -> Attribute Source #

The class attribute.

clip_ :: Text -> Attribute Source #

The clip attribute.

clip_path_ :: Text -> Attribute Source #

The clip-path attribute.

clip_rule_ :: Text -> Attribute Source #

The clipRule attribute.

clipPathUnits_ :: Text -> Attribute Source #

The clippathunits attribute.

color_ :: Text -> Attribute Source #

The color attribute.

color_interpolation_ :: Text -> Attribute Source #

The colorInterpolation attribute.

color_interpolation_filters_ :: Text -> Attribute Source #

The colorInterpolationFilters attribute.

color_profile_ :: Text -> Attribute Source #

The colorProfile attribute.

color_rendering_ :: Text -> Attribute Source #

The colorRendering attribute.

contentScriptType_ :: Text -> Attribute Source #

The contentscripttype attribute.

contentStyleType_ :: Text -> Attribute Source #

The contentstyletype attribute.

cx_ :: Text -> Attribute Source #

The cx attribute.

cy_ :: Text -> Attribute Source #

The cy attribute.

d_ :: Text -> Attribute Source #

The d attribute.

descent_ :: Text -> Attribute Source #

The descent attribute.

diffuseConstant_ :: Text -> Attribute Source #

The diffuseconstant attribute.

direction_ :: Text -> Attribute Source #

The direction attribute.

display_ :: Text -> Attribute Source #

The display attribute.

divisor_ :: Text -> Attribute Source #

The divisor attribute.

dominant_baseline_ :: Text -> Attribute Source #

The dominantBaseline attribute.

dur_ :: Text -> Attribute Source #

The dur attribute.

dx_ :: Text -> Attribute Source #

The dx attribute.

dy_ :: Text -> Attribute Source #

The dy attribute.

edgeMode_ :: Text -> Attribute Source #

The edgemode attribute.

elevation_ :: Text -> Attribute Source #

The elevation attribute.

enable_background_ :: Text -> Attribute Source #

The enableBackground attribute.

end_ :: Text -> Attribute Source #

The end attribute.

exponent_ :: Text -> Attribute Source #

The exponent attribute.

externalResourcesRequired_ :: Text -> Attribute Source #

The externalresourcesrequired attribute.

fill_ :: Text -> Attribute Source #

The fill attribute.

fill_opacity_ :: Text -> Attribute Source #

The fillOpacity attribute.

fill_rule_ :: Text -> Attribute Source #

The fillRule attribute.

filterRes_ :: Text -> Attribute Source #

The filterres attribute.

filterUnits_ :: Text -> Attribute Source #

The filterunits attribute.

flood_color_ :: Text -> Attribute Source #

The floodColor attribute.

flood_opacity_ :: Text -> Attribute Source #

The floodOpacity attribute.

font_family_ :: Text -> Attribute Source #

The fontFamily attribute.

font_size_ :: Text -> Attribute Source #

The fontSize attribute.

font_size_adjust_ :: Text -> Attribute Source #

The fontSizeAdjust attribute.

font_stretch_ :: Text -> Attribute Source #

The fontStretch attribute.

font_style_ :: Text -> Attribute Source #

The fontStyle attribute.

font_variant_ :: Text -> Attribute Source #

The fontVariant attribute.

font_weight_ :: Text -> Attribute Source #

The fontWeight attribute.

format_ :: Text -> Attribute Source #

The format attribute.

from_ :: Text -> Attribute Source #

The from attribute.

fx_ :: Text -> Attribute Source #

The fx attribute.

fy_ :: Text -> Attribute Source #

The fy attribute.

g1_ :: Text -> Attribute Source #

The g1 attribute.

g2_ :: Text -> Attribute Source #

The g2 attribute.

glyph_name_ :: Text -> Attribute Source #

The glyphName attribute.

glyph_orientation_horizontal_ :: Text -> Attribute Source #

The glyphOrientationHorizontal attribute.

glyph_orientation_vertical_ :: Text -> Attribute Source #

The glyphOrientationVertical attribute.

gradientTransform_ :: Text -> Attribute Source #

The -- | The gradienttransform@ attribute.

gradientUnits_ :: Text -> Attribute Source #

The gradientunits attribute.

hanging_ :: Text -> Attribute Source #

The hanging attribute.

height_ :: Text -> Attribute Source #

The height attribute.

horiz_adv_x_ :: Text -> Attribute Source #

The horizAdvX attribute.

horiz_origin_x_ :: Text -> Attribute Source #

The horizOriginX attribute.

horiz_origin_y_ :: Text -> Attribute Source #

The horizOriginY attribute.

id_ :: Text -> Attribute Source #

The id attribute.

ideographic_ :: Text -> Attribute Source #

The ideographic attribute.

image_rendering_ :: Text -> Attribute Source #

The imageRendering attribute.

in_ :: Text -> Attribute Source #

The in attribute.

in2_ :: Text -> Attribute Source #

The in2 attribute.

intercept_ :: Text -> Attribute Source #

The intercept attribute.

k_ :: Text -> Attribute Source #

The k attribute.

k1_ :: Text -> Attribute Source #

The k1 attribute.

k2_ :: Text -> Attribute Source #

The k2 attribute.

k3_ :: Text -> Attribute Source #

The k3 attribute.

k4_ :: Text -> Attribute Source #

The k4 attribute.

kernelMatrix_ :: Text -> Attribute Source #

The kernelmatrix attribute.

kernelUnitLength_ :: Text -> Attribute Source #

The kernelunitlength attribute.

kerning_ :: Text -> Attribute Source #

The kerning attribute.

keyPoints_ :: Text -> Attribute Source #

The keypoints attribute.

keySplines_ :: Text -> Attribute Source #

The keysplines attribute.

keyTimes_ :: Text -> Attribute Source #

The keytimes attribute.

lang_ :: Text -> Attribute Source #

The lang attribute.

lengthAdjust_ :: Text -> Attribute Source #

The lengthadjust attribute.

letter_spacing_ :: Text -> Attribute Source #

The letterSpacing attribute.

lighting_color_ :: Text -> Attribute Source #

The lightingColor attribute.

limitingConeAngle_ :: Text -> Attribute Source #

The limitingconeangle attribute.

local_ :: Text -> Attribute Source #

The local attribute.

marker_end_ :: Text -> Attribute Source #

The markerEnd attribute.

marker_mid_ :: Text -> Attribute Source #

The markerMid attribute.

marker_start_ :: Text -> Attribute Source #

The markerStart attribute.

markerHeight_ :: Text -> Attribute Source #

The markerheight attribute.

markerUnits_ :: Text -> Attribute Source #

The markerunits attribute.

markerWidth_ :: Text -> Attribute Source #

The markerwidth attribute.

maskContentUnits_ :: Text -> Attribute Source #

The maskcontentunits attribute.

maskUnits_ :: Text -> Attribute Source #

The maskunits attribute.

mathematical_ :: Text -> Attribute Source #

The mathematical attribute.

max_ :: Text -> Attribute Source #

The max attribute.

media_ :: Text -> Attribute Source #

The media attribute.

method_ :: Text -> Attribute Source #

The method attribute.

min_ :: Text -> Attribute Source #

The min attribute.

mode_ :: Text -> Attribute Source #

The mode attribute.

name_ :: Text -> Attribute Source #

The name attribute.

numOctaves_ :: Text -> Attribute Source #

The numoctaves attribute.

offset_ :: Text -> Attribute Source #

The offset attribute.

onabort_ :: Text -> Attribute Source #

The onabort attribute.

onactivate_ :: Text -> Attribute Source #

The onactivate attribute.

onbegin_ :: Text -> Attribute Source #

The onbegin attribute.

onclick_ :: Text -> Attribute Source #

The onclick attribute.

onend_ :: Text -> Attribute Source #

The onend attribute.

onerror_ :: Text -> Attribute Source #

The onerror attribute.

onfocusin_ :: Text -> Attribute Source #

The onfocusin attribute.

onfocusout_ :: Text -> Attribute Source #

The onfocusout attribute.

onload_ :: Text -> Attribute Source #

The onload attribute.

onmousedown_ :: Text -> Attribute Source #

The onmousedown attribute.

onmousemove_ :: Text -> Attribute Source #

The onmousemove attribute.

onmouseout_ :: Text -> Attribute Source #

The onmouseout attribute.

onmouseover_ :: Text -> Attribute Source #

The onmouseover attribute.

onmouseup_ :: Text -> Attribute Source #

The onmouseup attribute.

onrepeat_ :: Text -> Attribute Source #

The onrepeat attribute.

onresize_ :: Text -> Attribute Source #

The onresize attribute.

onscroll_ :: Text -> Attribute Source #

The onscroll attribute.

onunload_ :: Text -> Attribute Source #

The onunload attribute.

onzoom_ :: Text -> Attribute Source #

The onzoom attribute.

opacity_ :: Text -> Attribute Source #

The opacity attribute.

operator_ :: Text -> Attribute Source #

The operator attribute.

order_ :: Text -> Attribute Source #

The order attribute.

orient_ :: Text -> Attribute Source #

The orient attribute.

orientation_ :: Text -> Attribute Source #

The orientation attribute.

origin_ :: Text -> Attribute Source #

The origin attribute.

overflow_ :: Text -> Attribute Source #

The overflow attribute.

overline_position_ :: Text -> Attribute Source #

The overlinePosition attribute.

overline_thickness_ :: Text -> Attribute Source #

The overlineThickness attribute.

panose_1_ :: Text -> Attribute Source #

The panose1 attribute.

paint_order_ :: Text -> Attribute Source #

The paint-order attribute.

pathLength_ :: Text -> Attribute Source #

The pathlength attribute.

patternContentUnits_ :: Text -> Attribute Source #

The patterncontentunits attribute.

patternTransform_ :: Text -> Attribute Source #

The patterntransform attribute.

patternUnits_ :: Text -> Attribute Source #

The patternunits attribute.

pointer_events_ :: Text -> Attribute Source #

The pointerEvents attribute.

points_ :: Text -> Attribute Source #

The points attribute.

pointsAtX_ :: Text -> Attribute Source #

The pointsatx attribute.

pointsAtY_ :: Text -> Attribute Source #

The pointsaty attribute.

pointsAtZ_ :: Text -> Attribute Source #

The pointsatz attribute.

preserveAlpha_ :: Text -> Attribute Source #

The preservealpha attribute.

preserveAspectRatio_ :: Text -> Attribute Source #

The preserveaspectratio attribute.

primitiveUnits_ :: Text -> Attribute Source #

The primitiveunits attribute.

r_ :: Text -> Attribute Source #

The r attribute.

radius_ :: Text -> Attribute Source #

The radius attribute.

refX_ :: Text -> Attribute Source #

The refx attribute.

refY_ :: Text -> Attribute Source #

The refy attribute.

rendering_intent_ :: Text -> Attribute Source #

The renderingIntent attribute.

repeatCount_ :: Text -> Attribute Source #

The repeatcount attribute.

repeatDur_ :: Text -> Attribute Source #

The repeatdur attribute.

requiredExtensions_ :: Text -> Attribute Source #

The requiredextensions attribute.

requiredFeatures_ :: Text -> Attribute Source #

The requiredfeatures attribute.

restart_ :: Text -> Attribute Source #

The restart attribute.

result_ :: Text -> Attribute Source #

The result attribute.

rotate_ :: Text -> Attribute Source #

The rotate attribute.

rx_ :: Text -> Attribute Source #

The rx attribute.

ry_ :: Text -> Attribute Source #

The ry attribute.

scale_ :: Text -> Attribute Source #

The scale attribute.

seed_ :: Text -> Attribute Source #

The seed attribute.

shape_rendering_ :: Text -> Attribute Source #

The shapeRendering attribute.

slope_ :: Text -> Attribute Source #

The slope attribute.

spacing_ :: Text -> Attribute Source #

The spacing attribute.

specularConstant_ :: Text -> Attribute Source #

The specularconstant attribute.

specularExponent_ :: Text -> Attribute Source #

The specularexponent attribute.

spreadMethod_ :: Text -> Attribute Source #

The spreadmethod attribute.

startOffset_ :: Text -> Attribute Source #

The startoffset attribute.

stdDeviation_ :: Text -> Attribute Source #

The stddeviation attribute.

stemh_ :: Text -> Attribute Source #

The stemh attribute.

stemv_ :: Text -> Attribute Source #

The stemv attribute.

stitchTiles_ :: Text -> Attribute Source #

The stitchtiles attribute.

stop_color_ :: Text -> Attribute Source #

The stopColor attribute.

stop_opacity_ :: Text -> Attribute Source #

The stopOpacity attribute.

strikethrough_position_ :: Text -> Attribute Source #

The strikethroughPosition attribute.

strikethrough_thickness_ :: Text -> Attribute Source #

The strikethroughThickness attribute.

string_ :: Text -> Attribute Source #

The string attribute.

stroke_ :: Text -> Attribute Source #

The stroke attribute.

stroke_dasharray_ :: Text -> Attribute Source #

The strokeDasharray attribute.

stroke_dashoffset_ :: Text -> Attribute Source #

The strokeDashoffset attribute.

stroke_linecap_ :: Text -> Attribute Source #

The strokeLinecap attribute.

stroke_linejoin_ :: Text -> Attribute Source #

The strokeLinejoin attribute.

stroke_miterlimit_ :: Text -> Attribute Source #

The strokeMiterlimit attribute.

stroke_opacity_ :: Text -> Attribute Source #

The strokeOpacity attribute.

stroke_width_ :: Text -> Attribute Source #

The strokeWidth attribute.

surfaceScale_ :: Text -> Attribute Source #

The surfacescale attribute.

systemLanguage_ :: Text -> Attribute Source #

The systemlanguage attribute.

tableValues_ :: Text -> Attribute Source #

The tablevalues attribute.

target_ :: Text -> Attribute Source #

The target attribute.

targetX_ :: Text -> Attribute Source #

The targetx attribute.

targetY_ :: Text -> Attribute Source #

The targety attribute.

text_anchor_ :: Text -> Attribute Source #

The textAnchor attribute.

text_decoration_ :: Text -> Attribute Source #

The textDecoration attribute.

text_rendering_ :: Text -> Attribute Source #

The textRendering attribute.

textLength_ :: Text -> Attribute Source #

The textlength attribute.

to_ :: Text -> Attribute Source #

The to attribute.

transform_ :: Text -> Attribute Source #

The transform attribute.

type_ :: Text -> Attribute Source #

The type attribute.

u1_ :: Text -> Attribute Source #

The u1 attribute.

u2_ :: Text -> Attribute Source #

The u2 attribute.

underline_position_ :: Text -> Attribute Source #

The underlinePosition attribute.

underline_thickness_ :: Text -> Attribute Source #

The underlineThickness attribute.

unicode_ :: Text -> Attribute Source #

The unicode attribute.

unicode_bidi_ :: Text -> Attribute Source #

The unicodeBidi attribute.

unicode_range_ :: Text -> Attribute Source #

The unicodeRange attribute.

units_per_em_ :: Text -> Attribute Source #

The unitsPerEm attribute.

v_alphabetic_ :: Text -> Attribute Source #

The vAlphabetic attribute.

v_hanging_ :: Text -> Attribute Source #

The vHanging attribute.

v_ideographic_ :: Text -> Attribute Source #

The vIdeographic attribute.

v_mathematical_ :: Text -> Attribute Source #

The vMathematical attribute.

values_ :: Text -> Attribute Source #

The values attribute.

version_ :: Text -> Attribute Source #

The version attribute.

vert_adv_y_ :: Text -> Attribute Source #

The vertAdvY attribute.

vert_origin_x_ :: Text -> Attribute Source #

The vertOriginX attribute.

vert_origin_y_ :: Text -> Attribute Source #

The vertOriginY attribute.

viewBox_ :: Text -> Attribute Source #

The viewbox attribute.

viewTarget_ :: Text -> Attribute Source #

The viewtarget attribute.

visibility_ :: Text -> Attribute Source #

The visibility attribute.

width_ :: Text -> Attribute Source #

The width attribute.

widths_ :: Text -> Attribute Source #

The widths attribute.

word_spacing_ :: Text -> Attribute Source #

The wordSpacing attribute.

writing_mode_ :: Text -> Attribute Source #

The writingMode attribute.

x_ :: Text -> Attribute Source #

The x attribute.

x_height_ :: Text -> Attribute Source #

The xHeight attribute.

x1_ :: Text -> Attribute Source #

The x1 attribute.

x2_ :: Text -> Attribute Source #

The x2 attribute.

xChannelSelector_ :: Text -> Attribute Source #

The xchannelselector attribute.

xlinkActuate_ :: Text -> Attribute Source #

The xlinkActuate attribute.

xlinkArcrole_ :: Text -> Attribute Source #

The xlinkArcrole attribute.

xlinkHref_ :: Text -> Attribute Source #

The xlinkHref attribute.

xlinkRole_ :: Text -> Attribute Source #

The xlinkRole attribute.

xlinkShow_ :: Text -> Attribute Source #

The xlinkShow attribute.

xlinkTitle_ :: Text -> Attribute Source #

The xlinkTitle attribute.

xlinkType_ :: Text -> Attribute Source #

The xlinkType attribute.

xmlBase_ :: Text -> Attribute Source #

The xmlBase attribute.

xmlLang_ :: Text -> Attribute Source #

The xmlLang attribute.

xmlSpace_ :: Text -> Attribute Source #

The xmlSpace attribute.

y_ :: Text -> Attribute Source #

The y attribute.

y1_ :: Text -> Attribute Source #

The y1 attribute.

y2_ :: Text -> Attribute Source #

The y2 attribute.

yChannelselector_ :: Text -> Attribute Source #

The ychannelselector attribute.

z_ :: Text -> Attribute Source #

The z attribute.

zoomAndPan_ :: Text -> Attribute Source #

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 #