mauroc8 / elm-html-pipeline / Html.Pipeline


type Element msg

Represents an HTML element node.

In particular, an element node is a node that has a tag name, a list of attributes and a list of children.

Other types of HTML nodes (for example text nodes) don't have any of those.

node : String -> Element msg

Creates an empty Element from a HTML tag name.

addAttributes : List (Html.Attribute msg) -> Element msg -> Element msg

Appends attributes to an existing Element.

node "div"
    |> addAttributes
        [ Html.Attributes.class "container"
        ]

addChildren : List (Html msg) -> Element msg -> Element msg

Appends children to an existing Element.

node "div"
    |> addChildren
        [ Html.text "Hello,"
        , Html.text " world"
        ]

toHtml : Element msg -> Html msg

Converts an Element into an elm Html value, closing the pipeline.

fold : (String -> List (Html.Attribute msg) -> List (Html msg) -> b) -> Element msg -> b

This function allows you to do whatever you want with the accumulated attributes and children.

It is exported for testing purposes, you shouldn't need it.