| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.Fmt.Html
Description
Html5 formatting.
The API is similar to https://hackage.haskell.org/package/blaze-html.
Synopsis
- type Html a = Fmt LogStr a a
- data Attr
- toHtml :: ToLogStr s => s -> Html a
- comment :: ToLogStr s => s -> Html a
- class Element html where
- (!?) :: Element html => html -> (Bool, Attr) -> html
- numbers :: Int -> Html LogStr
- docType :: Html a
- docTypeHtml :: Html a -> Html a
- a :: Html a -> Html a
- abbr :: Html a -> Html a
- address :: Html a -> Html a
- area :: Html a
- article :: Html a -> Html a
- aside :: Html a -> Html a
- audio :: Html a -> Html a
- b :: Html a -> Html a
- base :: Html a
- bdo :: Html a -> Html a
- blockquote :: Html a -> Html a
- body :: Html a -> Html a
- br :: Html a
- button :: Html a -> Html a
- canvas :: Html a -> Html a
- caption :: Html a -> Html a
- cite :: Html a -> Html a
- code :: Html a -> Html a
- col :: Html a
- colgroup :: Html a -> Html a
- command :: Html a -> Html a
- datalist :: Html a -> Html a
- dd :: Html a -> Html a
- del :: Html a -> Html a
- details :: Html a -> Html a
- dfn :: Html a -> Html a
- div :: Html a -> Html a
- dl :: Html a -> Html a
- dt :: Html a -> Html a
- em :: Html a -> Html a
- embed :: Html a
- fieldset :: Html a -> Html a
- figcaption :: Html a -> Html a
- figure :: Html a -> Html a
- footer :: Html a -> Html a
- form :: Html a -> Html a
- h1 :: Html a -> Html a
- h2 :: Html a -> Html a
- h3 :: Html a -> Html a
- h4 :: Html a -> Html a
- h5 :: Html a -> Html a
- h6 :: Html a -> Html a
- head :: Html a -> Html a
- header :: Html a -> Html a
- hgroup :: Html a -> Html a
- hr :: Html a
- html :: Html a -> Html a
- i :: Html a -> Html a
- iframe :: Html a -> Html a
- img :: Html a
- input :: Html a
- ins :: Html a -> Html a
- kbd :: Html a -> Html a
- keygen :: Html a
- label :: Html a -> Html a
- legend :: Html a -> Html a
- li :: Html a -> Html a
- link :: Html a
- main :: Html a -> Html a
- map :: Html a -> Html a
- mark :: Html a -> Html a
- menu :: Html a -> Html a
- menuitem :: Html a
- meta :: Html a
- meter :: Html a -> Html a
- nav :: Html a -> Html a
- noscript :: Html a -> Html a
- object :: Html a -> Html a
- ol :: Html a -> Html a
- optgroup :: Html a -> Html a
- option :: Html a -> Html a
- output :: Html a -> Html a
- p :: Html a -> Html a
- param :: Html a
- pre :: Html a -> Html a
- progress :: Html a -> Html a
- q :: Html a -> Html a
- rp :: Html a -> Html a
- rt :: Html a -> Html a
- ruby :: Html a -> Html a
- samp :: Html a -> Html a
- script :: Html a -> Html a
- section :: Html a -> Html a
- select :: Html a -> Html a
- small :: Html a -> Html a
- source :: Html a
- span :: Html a -> Html a
- strong :: Html a -> Html a
- style :: Html a -> Html a
- sub :: Html a -> Html a
- summary :: Html a -> Html a
- sup :: Html a -> Html a
- table :: Html a -> Html a
- tbody :: Html a -> Html a
- td :: Html a -> Html a
- textarea :: Html a -> Html a
- tfoot :: Html a -> Html a
- th :: Html a -> Html a
- thead :: Html a -> Html a
- time :: Html a -> Html a
- title :: Html a -> Html a
- tr :: Html a -> Html a
- track :: Html a
- u :: Html a -> Html a
- ul :: Html a -> Html a
- var :: Html a -> Html a
- video :: Html a -> Html a
- wbr :: Html a
- contact :: Html LogStr
Html
type Html a = Fmt LogStr a a #
Format HTML
For example:
contact ::HtmlLogStrcontact =p"You can reach me at"%ul.spr.li$ do c1 <-a!hrefString "https://example.com" $ Website c2 <-String "mailto:cmk@example.com" $ Emaila!hrefpure$ c1<>c2
generates the following output:
"<p>You can reach me at</p><ul><li><a href=\"https://foo.com\">Web</a></li><li><a href=\"mailto:cmk@foo.com\">Email</a></li></ul>"
Type for an attribute.
Apply an attribute to an HTML tag.
The interface is similar to https://hackage.haskell.org/package/blaze-builder.
You should not define your own instances of this class.
Methods
Apply an attribute to an element.
>>>printf $ img ! src "foo.png"<img src="foo.png" />
This can be used on nested elements as well:
>>>printf $ p ! style "float: right" $ "Hello!"<p style="float: right">Hello!</p>
(!?) :: Element html => html -> (Bool, Attr) -> html #
Shorthand for setting an attribute depending on a conditional.
Example:
p !? (isBig, A.class "big") $ "Hello"
Gives the same result as:
(if isBig then p ! A.class "big" else p) "Hello"
Elements
Arguments
| :: Html a | The document type HTML. |
Combinator for the document type. This should be placed at the top of every HTML page.
Example:
docType
Result:
<!DOCTYPE HTML>
Combinator for the <html> element. This combinator will also
insert the correct doctype.
Example:
docTypeHtml $ span $ fmt "foo"
Result:
<!DOCTYPE HTML> <html><span>foo</span></html>
Combinator for the <a> element.
Example:
a $ span $ fmt "foo"
Result:
<a><span>foo</span></a>
Combinator for the <abbr> element.
Example:
abbr $ span $ fmt "foo"
Result:
<abbr><span>foo</span></abbr>
Combinator for the <address> element.
Example:
address $ span $ fmt "foo"
Result:
<address><span>foo</span></address>
Arguments
| :: Html a | Resulting HTML. |
Combinator for the <area /> element.
Example:
area
Result:
<area />
Combinator for the <article> element.
Example:
article $ span $ fmt "foo"
Result:
<article><span>foo</span></article>
Combinator for the <aside> element.
Example:
aside $ span $ fmt "foo"
Result:
<aside><span>foo</span></aside>
Combinator for the <audio> element.
Example:
audio $ span $ fmt "foo"
Result:
<audio><span>foo</span></audio>
Combinator for the <b> element.
Example:
b $ span $ fmt "foo"
Result:
<b><span>foo</span></b>
Arguments
| :: Html a | Resulting HTML. |
Combinator for the <base /> element.
Example:
base
Result:
<base />
Combinator for the <bdo> element.
Example:
bdo $ span $ fmt "foo"
Result:
<bdo><span>foo</span></bdo>
Combinator for the <blockquote> element.
Example:
blockquote $ span $ fmt "foo"
Result:
<blockquote><span>foo</span></blockquote>
Combinator for the <body> element.
Example:
body $ span $ fmt "foo"
Result:
<body><span>foo</span></body>
Combinator for the <button> element.
Example:
button $ span $ fmt "foo"
Result:
<button><span>foo</span></button>
Combinator for the <canvas> element.
Example:
canvas $ span $ fmt "foo"
Result:
<canvas><span>foo</span></canvas>
Combinator for the <caption> element.
Example:
caption $ span $ fmt "foo"
Result:
<caption><span>foo</span></caption>
Combinator for the <cite> element.
Example:
cite $ span $ fmt "foo"
Result:
<cite><span>foo</span></cite>
Combinator for the <code> element.
Example:
code $ span $ fmt "foo"
Result:
<code><span>foo</span></code>
Combinator for the <colgroup> element.
Example:
colgroup $ span $ fmt "foo"
Result:
<colgroup><span>foo</span></colgroup>
Combinator for the <command> element.
Example:
command $ span $ fmt "foo"
Result:
<command><span>foo</span></command>
Combinator for the <datalist> element.
Example:
datalist $ span $ fmt "foo"
Result:
<datalist><span>foo</span></datalist>
Combinator for the <dd> element.
Example:
dd $ span $ fmt "foo"
Result:
<dd><span>foo</span></dd>
Combinator for the <del> element.
Example:
del $ span $ fmt "foo"
Result:
<del><span>foo</span></del>
Combinator for the <details> element.
Example:
details $ span $ fmt "foo"
Result:
<details><span>foo</span></details>
Combinator for the <dfn> element.
Example:
dfn $ span $ fmt "foo"
Result:
<dfn><span>foo</span></dfn>
Combinator for the <div> element.
Example:
div $ span $ fmt "foo"
Result:
<div><span>foo</span></div>
Combinator for the <dl> element.
Example:
dl $ span $ fmt "foo"
Result:
<dl><span>foo</span></dl>
Combinator for the <dt> element.
Example:
dt $ span $ fmt "foo"
Result:
<dt><span>foo</span></dt>
Combinator for the <em> element.
Example:
em $ span $ fmt "foo"
Result:
<em><span>foo</span></em>
Arguments
| :: Html a | Resulting HTML. |
Combinator for the <embed /> element.
Example:
embed
Result:
<embed />
Combinator for the <fieldset> element.
Example:
fieldset $ span $ fmt "foo"
Result:
<fieldset><span>foo</span></fieldset>
Combinator for the <figcaption> element.
Example:
figcaption $ span $ fmt "foo"
Result:
<figcaption><span>foo</span></figcaption>
Combinator for the <figure> element.
Example:
figure $ span $ fmt "foo"
Result:
<figure><span>foo</span></figure>
Combinator for the <footer> element.
Example:
footer $ span $ fmt "foo"
Result:
<footer><span>foo</span></footer>
Combinator for the <form> element.
Example:
form $ span $ fmt "foo"
Result:
<form><span>foo</span></form>
Combinator for the <h1> element.
Example:
h1 $ span $ fmt "foo"
Result:
<h1><span>foo</span></h1>
Combinator for the <h2> element.
Example:
h2 $ span $ fmt "foo"
Result:
<h2><span>foo</span></h2>
Combinator for the <h3> element.
Example:
h3 $ span $ fmt "foo"
Result:
<h3><span>foo</span></h3>
Combinator for the <h4> element.
Example:
h4 $ span $ fmt "foo"
Result:
<h4><span>foo</span></h4>
Combinator for the <h5> element.
Example:
h5 $ span $ fmt "foo"
Result:
<h5><span>foo</span></h5>
Combinator for the <h6> element.
Example:
h6 $ span $ fmt "foo"
Result:
<h6><span>foo</span></h6>
Combinator for the <head> element.
Example:
head $ span $ fmt "foo"
Result:
<head><span>foo</span></head>
Combinator for the <header> element.
Example:
header $ span $ fmt "foo"
Result:
<header><span>foo</span></header>
Combinator for the <hgroup> element.
Example:
hgroup $ span $ fmt "foo"
Result:
<hgroup><span>foo</span></hgroup>
Combinator for the <html> element.
Example:
html $ span $ fmt "foo"
Result:
<html><span>foo</span></html>
Combinator for the <i> element.
Example:
i $ span $ fmt "foo"
Result:
<i><span>foo</span></i>
Combinator for the <iframe> element.
Example:
iframe $ span $ fmt "foo"
Result:
<iframe><span>foo</span></iframe>
Arguments
| :: Html a | Resulting HTML. |
Combinator for the <input /> element.
Example:
input
Result:
<input />
Combinator for the <ins> element.
Example:
ins $ span $ fmt "foo"
Result:
<ins><span>foo</span></ins>
Combinator for the <kbd> element.
Example:
kbd $ span $ fmt "foo"
Result:
<kbd><span>foo</span></kbd>
Arguments
| :: Html a | Resulting HTML. |
Combinator for the <keygen /> element.
Example:
keygen
Result:
<keygen />
Combinator for the <label> element.
Example:
label $ span $ fmt "foo"
Result:
<label><span>foo</span></label>
Combinator for the <legend> element.
Example:
legend $ span $ fmt "foo"
Result:
<legend><span>foo</span></legend>
Combinator for the <li> element.
Example:
li $ span $ fmt "foo"
Result:
<li><span>foo</span></li>
Arguments
| :: Html a | Resulting HTML. |
Combinator for the <link /> element.
Example:
link
Result:
<link />
Combinator for the <main> element.
Example:
main $ span $ fmt "foo"
Result:
<main><span>foo</span></main>
Combinator for the <map> element.
Example:
map $ span $ fmt "foo"
Result:
<map><span>foo</span></map>
Combinator for the <mark> element.
Example:
mark $ span $ fmt "foo"
Result:
<mark><span>foo</span></mark>
Combinator for the <menu> element.
Example:
menu $ span $ fmt "foo"
Result:
<menu><span>foo</span></menu>
Arguments
| :: Html a | Resulting HTML. |
Combinator for the <menuitem /> element.
Example:
menuitem
Result:
<menuitem />
Arguments
| :: Html a | Resulting HTML. |
Combinator for the <meta /> element.
Example:
meta
Result:
<meta />
Combinator for the <meter> element.
Example:
meter $ span $ fmt "foo"
Result:
<meter><span>foo</span></meter>
Combinator for the <nav> element.
Example:
nav $ span $ fmt "foo"
Result:
<nav><span>foo</span></nav>
Combinator for the <noscript> element.
Example:
noscript $ span $ fmt "foo"
Result:
<noscript><span>foo</span></noscript>
Combinator for the <object> element.
Example:
object $ span $ fmt "foo"
Result:
<object><span>foo</span></object>
Combinator for the <ol> element.
Example:
ol $ span $ fmt "foo"
Result:
<ol><span>foo</span></ol>
Combinator for the <optgroup> element.
Example:
optgroup $ span $ fmt "foo"
Result:
<optgroup><span>foo</span></optgroup>
Combinator for the <option> element.
Example:
option $ span $ fmt "foo"
Result:
<option><span>foo</span></option>
Combinator for the <output> element.
Example:
output $ span $ fmt "foo"
Result:
<output><span>foo</span></output>
Combinator for the <p> element.
Example:
p $ span $ fmt "foo"
Result:
<p><span>foo</span></p>
Arguments
| :: Html a | Resulting HTML. |
Combinator for the <param /> element.
Example:
param
Result:
<param />
Combinator for the <pre> element.
Example:
pre $ span $ fmt "foo"
Result:
<pre><span>foo</span></pre>
Combinator for the <progress> element.
Example:
progress $ span $ fmt "foo"
Result:
<progress><span>foo</span></progress>
Combinator for the <q> element.
Example:
q $ span $ fmt "foo"
Result:
<q><span>foo</span></q>
Combinator for the <rp> element.
Example:
rp $ span $ fmt "foo"
Result:
<rp><span>foo</span></rp>
Combinator for the <rt> element.
Example:
rt $ span $ fmt "foo"
Result:
<rt><span>foo</span></rt>
Combinator for the <ruby> element.
Example:
ruby $ span $ fmt "foo"
Result:
<ruby><span>foo</span></ruby>
Combinator for the <samp> element.
Example:
samp $ span $ fmt "foo"
Result:
<samp><span>foo</span></samp>
Combinator for the <script> element.
Example:
script $ span $ fmt "foo"
Result:
<script><span>foo</span></script>
Combinator for the <section> element.
Example:
section $ span $ fmt "foo"
Result:
<section><span>foo</span></section>
Combinator for the <select> element.
Example:
select $ span $ fmt "foo"
Result:
<select><span>foo</span></select>
Combinator for the <small> element.
Example:
small $ span $ fmt "foo"
Result:
<small><span>foo</span></small>
Arguments
| :: Html a | Resulting HTML. |
Combinator for the <source /> element.
Example:
source
Result:
<source />
Combinator for the <span> element.
Example:
span $ span $ fmt "foo"
Result:
<span><span>foo</span></span>
Combinator for the <strong> element.
Example:
strong $ span $ fmt "foo"
Result:
<strong><span>foo</span></strong>
Combinator for the <style> element.
Example:
style $ span $ fmt "foo"
Result:
<style><span>foo</span></style>
Combinator for the <sub> element.
Example:
sub $ span $ fmt "foo"
Result:
<sub><span>foo</span></sub>
Combinator for the <summary> element.
Example:
summary $ span $ fmt "foo"
Result:
<summary><span>foo</span></summary>
Combinator for the <sup> element.
Example:
sup $ span $ fmt "foo"
Result:
<sup><span>foo</span></sup>
Combinator for the <table> element.
Example:
table $ span $ fmt "foo"
Result:
<table><span>foo</span></table>
Combinator for the <tbody> element.
Example:
tbody $ span $ fmt "foo"
Result:
<tbody><span>foo</span></tbody>
Combinator for the <td> element.
Example:
td $ span $ fmt "foo"
Result:
<td><span>foo</span></td>
Combinator for the <textarea> element.
Example:
textarea $ span $ fmt "foo"
Result:
<textarea><span>foo</span></textarea>
Combinator for the <tfoot> element.
Example:
tfoot $ span $ fmt "foo"
Result:
<tfoot><span>foo</span></tfoot>
Combinator for the <th> element.
Example:
th $ span $ fmt "foo"
Result:
<th><span>foo</span></th>
Combinator for the <thead> element.
Example:
thead $ span $ fmt "foo"
Result:
<thead><span>foo</span></thead>
Combinator for the <time> element.
Example:
time $ span $ fmt "foo"
Result:
<time><span>foo</span></time>
Combinator for the <title> element.
Example:
title $ span $ fmt "foo"
Result:
<title><span>foo</span></title>
Combinator for the <tr> element.
Example:
tr $ span $ fmt "foo"
Result:
<tr><span>foo</span></tr>
Arguments
| :: Html a | Resulting HTML. |
Combinator for the <track /> element.
Example:
track
Result:
<track />
Combinator for the <u> element.
Example:
u $ span $ fmt "foo"
Result:
<u><span>foo</span></u>
Combinator for the <ul> element.
Example:
ul $ span $ fmt "foo"
Result:
<ul><span>foo</span></ul>
Combinator for the <var> element.
Example:
var $ span $ fmt "foo"
Result:
<var><span>foo</span></var>
Combinator for the <video> element.
Example:
video $ span $ fmt "foo"
Result:
<video><span>foo</span></video>