tricycle / elm-actor-framework-template-html / Framework.Template.Html


type alias HtmlTemplate appActors =
Internal.HtmlTemplate.HtmlTemplate appActors

Your parsed template that originated from a string containing valid Html

Creation

blank : HtmlTemplate appActors

An empty, blank HtmlTemplate

parse : Framework.Template.Components.Components appActors -> String -> Result String (HtmlTemplate appActors)

Parse a string containing valid Html into an HtmlTemplate

Add Components to replace Html Elements with your Actors based on their nodeNames. (e.g. <my-actor></my-actor>)

fromNodes : List (Framework.Template.Node appActors) -> HtmlTemplate appActors

Turn a list of Nodes into an HtmlTemplate

This could be useful for when you use your own Html Parser.

Rendering

toNodes : HtmlTemplate appActors -> List (Framework.Template.Node appActors)

Turn a HtmlTemplate into a list of Nodes

This could be useful for when you want to write or use another method of rendering the template in question.

render : Dict String Framework.Actor.Pid -> (Framework.Actor.Pid -> Maybe (Html msg)) -> HtmlTemplate appActors -> List (Html msg)

Render your template

renderAndInterpolate : Dict String Framework.Actor.Pid -> Dict String String -> (Framework.Actor.Pid -> Maybe (Html msg)) -> HtmlTemplate appActors -> List (Html msg)

Render your template and interpolate any string matching your interpolation dictionary.

renderAndInterpolate
    Dict.empty
    (Dict.fromList [ ( "foo", "bar" ) ])
    (fromNodes [ Text "<p>#[foo]</p>" ])
    temmplate

toString : HtmlTemplate appActors -> String

Turn a HtmlTemplate into a string

Utility

getActorsToSpawn : HtmlTemplate appActors -> List { actor : appActors, reference : String, actorElement : Framework.Template.ActorElement appActors }

Get the actor, reference and original complete node from a template that are meant to be spawned.

The String is a reference that can be used on the render function in combination with a Pid to render the Actors output.