p [Hello world!]
Changes it to: p [[Hello ] b[world!]] p [Hello world!]
Changes it to: p [[Hello ] b[world!]]Every HTML tag (except for `text`) is an implementation of the base function `node`, which is:
node : String -> List Attr msg -> List Html msg -> Html msg
So in the base library, the `p` tag is implemented as p : List Attr msg -> List Html msg -> Html msg
p = node "p"
Which means that in Elm, the above content would look like this: p [] [ text "Hello ", b [] [ text "World" ] ]
i.e., every HTML tag can accept as parameters: - A list of attributes
- A list of child tags
I've found it to be very elegant to work with; and with a good auto-formatter, it's really easy to build complicated HTML without losing your place and dropping a closing tag.The advantage of a Jevko-based format over the above is that it has the simplicity and elegance parameters (IMO) cranked up to maximum! ;)
Now, for the tool support...
This is one way. I've experimented with many others. Some semi-documented here:
https://github.com/jevko/markup-experiments
Some ways don't need additional level of nesting, but it's a trade-off.
In the end something like the way you linked is my favorite, because it's very simple.
It also gives you explicit control over your text nodes.
Attributes can also be added in many ways, but I think I prefer them simply looking like child nodes, except with `=` appended to attribute name:
p [class=[sth] [content]]
Technically you can mix attributes and elements this way, but it does no harm.