html_writer v0.2.2 HtmlWriter

Provide helper macros to write html programatically into a chardata

all macros in this module take an chardata as first argument and put more data in it as the return value

Link to this section Summary

Functions

Like ~>, but reverse the order For example

Like bind_to, but ignore nil or false For example

build non-void element a

build non-void element article

build non-void element b

helper macro to bind a value to a name, in order to maintain flow of the pipe operator. For example:

build non-void element blockquote

build non-void element body

build void element br

build non-void element button

build non-void element code

build non-void element del

build non-void element div

build a non-void element, which is an element that may have inner text. It may also have attributes. Don't call this unless you are making a custom element; use the element specific funcions instead.

build non-void element em

escape the string to be HTML safe

export the data. Since the data is a list, so all it does for now is Enum.reverse()

build non-void element form

build a html fragment with a builder function

build a html fragment with a predefined header string or io_list

build non-void element h1

build non-void element h2

build non-void element h3

build non-void element h4

build non-void element h5

build non-void element h6

build non-void element head

build void element hr

build non-void element html

build non-void element i

build void element img

build non-void element input

Invoke the func with s. This is used to keep the pipe flowing

build non-void element label

build non-void element li

build void element link

build void element meta

build non-void element nav

start with minimum boilerplate

build non-void element ol

build non-void element option

build non-void element p

build non-void element pre

This is Enum.reduce with first 2 arguments switched order.

build non-void element script

build non-void element section

build non-void element select

build non-void element slot

build non-void element span

build non-void element strong

build non-void element style

build non-void element table

build a void-element, which is an element that should not have inner text. It may have attributes though. Don't call this unless you are making a custom element; use the element specific funcions instead.

build non-void element tbody

build non-void element td

build non-void element template

Just add some text. Please note no text is escaped

build non-void element textarea

build non-void element th

build non-void element thead

build non-void element title

build non-void element tr

build non-void element u

build non-void element ul

Link to this section Functions

Link to this macro

name <~ value

(macro)

Like ~>, but reverse the order For example:

v <~ if(condition?, do: do_something(v))

which is shorter than:

v = if(condition?, do: do_something(v), else: v)
Link to this macro

value ~> name

(macro)

Like bind_to, but ignore nil or false For example:

v
|> do_someting()
|> do_something_else()
~> v

This feel better than doing the assignment

Link to this macro

a(s, inner, attrs \\ [])

(macro)

build non-void element a

Link to this macro

article(s, inner, attrs \\ [])

(macro)

build non-void element article

Link to this macro

b(s, inner, attrs \\ [])

(macro)

build non-void element b

Link to this macro

bind_to(value, name)

(macro)

helper macro to bind a value to a name, in order to maintain flow of the pipe operator. For example:

v
|> do_someting()
|> do_something_else()
|> bind_to(v)

This feel better than doing the assignment

Link to this macro

blockquote(s, inner, attrs \\ [])

(macro)

build non-void element blockquote

Link to this macro

body(s, inner, attrs \\ [])

(macro)

build non-void element body

Link to this macro

br(s, attrs \\ [])

(macro)

build void element br

Link to this macro

button(s, inner, attrs \\ [])

(macro)

build non-void element button

Link to this macro

code(s, inner, attrs \\ [])

(macro)

build non-void element code

Link to this macro

del(s, inner, attrs \\ [])

(macro)

build non-void element del

Link to this macro

div(s, inner, attrs \\ [])

(macro)

build non-void element div

Link to this function

element(s, tag, content, attrs \\ [])

build a non-void element, which is an element that may have inner text. It may also have attributes. Don't call this unless you are making a custom element; use the element specific funcions instead.

tag is the tag name. inner can be nil, a string or a function with arity of 1 that build inner text attr are a keyword list of attrbutes, each value can be a string, an list of strings, or nil

Link to this macro

em(s, inner, attrs \\ [])

(macro)

build non-void element em

escape the string to be HTML safe

Link to this macro

export(s)

(macro)

export the data. Since the data is a list, so all it does for now is Enum.reverse()

Link to this macro

form(s, inner, attrs \\ [])

(macro)

build non-void element form

build a html fragment with a builder function

Link to this function

fragment(header, f)

build a html fragment with a predefined header string or io_list

Link to this macro

h1(s, inner, attrs \\ [])

(macro)

build non-void element h1

Link to this macro

h2(s, inner, attrs \\ [])

(macro)

build non-void element h2

Link to this macro

h3(s, inner, attrs \\ [])

(macro)

build non-void element h3

Link to this macro

h4(s, inner, attrs \\ [])

(macro)

build non-void element h4

Link to this macro

h5(s, inner, attrs \\ [])

(macro)

build non-void element h5

Link to this macro

h6(s, inner, attrs \\ [])

(macro)

build non-void element h6

Link to this macro

head(s, inner, attrs \\ [])

(macro)

build non-void element head

Link to this macro

hr(s, attrs \\ [])

(macro)

build void element hr

Link to this macro

html(s, inner, attrs \\ [])

(macro)

build non-void element html

Link to this macro

i(s, inner, attrs \\ [])

(macro)

build non-void element i

Link to this macro

img(s, attrs \\ [])

(macro)

build void element img

Link to this macro

input(s, inner, attrs \\ [])

(macro)

build non-void element input

Link to this macro

invoke(s, func)

(macro)

Invoke the func with s. This is used to keep the pipe flowing

Link to this macro

label(s, inner, attrs \\ [])

(macro)

build non-void element label

Link to this macro

li(s, inner, attrs \\ [])

(macro)

build non-void element li

Link to this macro

link(s, attrs \\ [])

(macro)

build void element link

Link to this macro

meta(s, attrs \\ [])

(macro)

build void element meta

Link to this macro

new_html()

(macro)

start with minimum boilerplate

Link to this macro

ol(s, inner, attrs \\ [])

(macro)

build non-void element ol

Link to this macro

option(s, inner, attrs \\ [])

(macro)

build non-void element option

Link to this macro

p(s, inner, attrs \\ [])

(macro)

build non-void element p

Link to this macro

pre(s, inner, attrs \\ [])

(macro)

build non-void element pre

Link to this macro

roll_in(s, enum, function)

(macro)

This is Enum.reduce with first 2 arguments switched order.

For example:

h
|> roll_in(list, fn item, h ->
  h
  |> do_something_with(item)
end)

Using this one can maintian flow of the pipe chain.

Link to this macro

script(s, inner, attrs \\ [])

(macro)

build non-void element script

Link to this macro

section(s, inner, attrs \\ [])

(macro)

build non-void element section

Link to this macro

select(s, inner, attrs \\ [])

(macro)

build non-void element select

Link to this macro

slot(s, inner, attrs \\ [])

(macro)

build non-void element slot

Link to this macro

span(s, inner, attrs \\ [])

(macro)

build non-void element span

Link to this macro

strong(s, inner, attrs \\ [])

(macro)

build non-void element strong

Link to this macro

style(s, inner, attrs \\ [])

(macro)

build non-void element style

Link to this macro

table(s, inner, attrs \\ [])

(macro)

build non-void element table

Link to this function

tag(s, tag, attrs \\ [])

build a void-element, which is an element that should not have inner text. It may have attributes though. Don't call this unless you are making a custom element; use the element specific funcions instead.

tag is the tag name. attr are a keyword list of attrbutes, each value can be a string, an list of strings, or nil

Link to this macro

tbody(s, inner, attrs \\ [])

(macro)

build non-void element tbody

Link to this macro

td(s, inner, attrs \\ [])

(macro)

build non-void element td

Link to this macro

template(s, inner, attrs \\ [])

(macro)

build non-void element template

Link to this macro

text(s, text)

(macro)

Just add some text. Please note no text is escaped

Link to this macro

textarea(s, inner, attrs \\ [])

(macro)

build non-void element textarea

Link to this macro

th(s, inner, attrs \\ [])

(macro)

build non-void element th

Link to this macro

thead(s, inner, attrs \\ [])

(macro)

build non-void element thead

Link to this macro

title(s, inner, attrs \\ [])

(macro)

build non-void element title

Link to this macro

tr(s, inner, attrs \\ [])

(macro)

build non-void element tr

Link to this macro

u(s, inner, attrs \\ [])

(macro)

build non-void element u

Link to this macro

ul(s, inner, attrs \\ [])

(macro)

build non-void element ul