html_writer v0.2.1 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 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
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
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)
Like bind_to, but ignore nil or false For example:
v
|> do_someting()
|> do_something_else()
~> v
This feel better than doing the assignment
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:
v
|> do_someting()
|> do_something_else()
|> bind_to(v)
This feel better than doing the assignment
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
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
build non-void element em
escape(str)
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
fragment(f)
build a html fragment with a builder function
fragment(header, f)
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
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.
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.
build non-void element script
build non-void element section
build non-void element select
build non-void element span
build non-void element strong
build non-void element style
build non-void element table
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
build non-void element tbody
build non-void element td
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