eeue56/elm-html-in-elm/2.0.0

NOTE: this package is not compatible with Elm 0.19.1

ElmHtml.InternalTypes

Internal types used to represent Elm Html in pure Elm

type ElmHtml
= TextTag TextTagRecord
| NodeEntry NodeRecord
| CustomNode CustomNodeRecord
| MarkdownNode MarkdownNodeRecord
| NoOp

Type tree for representing Elm's Html

  • TextTag is just a plain old bit of text.
  • NodeEntry is an actual HTML node, e.g a div
  • CustomNode are nodes defined to work with the renderer in some way, e.g webgl/markdown
  • MarkdownNode is just a wrapper for CustomNode designed just for markdown
type alias TextTagRecord =
{ text : String }

Text tags just contain text

type alias NodeRecord =
{ tag : String
, children : List ElmHtml
, facts : Facts
, descendantsCount : Int
}

A node contains the tag as a string, the children, the facts (e.g attributes) and descendantsCount

type alias CustomNodeRecord =
{ facts : Facts
, model : Value
}

Custom nodes contain facts (e.g attributes) and a json value for the model

type alias MarkdownNodeRecord =
{ facts : Facts
, model : MarkdownModel
}

A markdown node contains facts (e.g attributes) and the model used by markdown

type alias Facts =
{ styles : Dict String String
, events : Maybe Value
, attributeNamespace : Maybe Value
, stringAttributes : Dict String String
, boolAttributes : Dict String Bool
}

Facts contain various dictionaries and values for a node

  • styles are a mapping of rules
  • events may be a json object containing event handlers
  • attributes are pulled out into stringAttributes and boolAttributes - things with string values go into stringAttributes, things with bool values go into boolAttributes
decodeElmHtml : Decoder ElmHtml

decode a json object into ElmHtml

emptyFacts : Facts

Just empty facts