Quickly render HTML in Elm.
The HTML part of a TEPA application looks something like this:
import Tepa.Html as Html exposing (Html)
import Tepa.Mixin as Mixin
view : Layer Memory -> Html
view =
Tepa.layerView <|
\{ state, setKey, values } ->
Html.div []
[ Html.button
[ Mixin.attribute "type" "button"
, setKey "button-decrement"
]
[ Html.text "-"
]
, Html.div []
[ Html.text (String.fromInt state.count)
]
, Html.button
[ Mixin.attribute "type" "button"
, setKey "button-increment"
]
[ Html.text "+"
]
]
type alias Memory =
{ count : Int
}If you call view you get something like this:
<div>
<button type="button">-</button>
<div>42</div>
<button type="button">+</button>
</div>Just put plain text in the DOM. It will escape the string so that it appears exactly as you specify.
General way to create HTML nodes. It is used to define all of the helper functions in this library.
div : List Mixin -> List Html -> Html
div mixins children =
node "div" mixins childrenYou can use this to create custom nodes if you need to create something that is not covered by the helper functions in this library.
The Mixin is bunch of attributes on your Html. Learn more in the
Tepa.Mixin module.
Works just like node, but you add a unique identifier to each child node.
You want this when you have a list of nodes that is changing: adding
nodes, removing nodes, etc. In these cases, the unique identifiers help make
the DOM modifications more efficient.
This is the TEPA version of Html.Keyed.node.
Represents a generic container with no special meaning.
See MDN document for details.
Represents text with no specific meaning.
See MDN document for details.
Defines a portion that should be displayed as a paragraph.
See MDN document for details.
Represents a hyperlink, linking to another resource.
See MDN document for details.
Represents a button.
See MDN document for details.
Represents a typed data field allowing the user to edit the data.
See MDN document for details.
Represents a multiline text edit control.
See MDN document for details.
Represents a control allowing selection among a set of options.
See MDN document for details.
Represents an option in a select element or a suggestion of a datalist
element.
See MDN document for details.
The core building block used to build up HTML. Here we create an
Htmlvalue with no attributes and one child: