This module contains some useful functions for parsing and rendering Html.
Render some html if a boolean expression evaluates to False.
If the boolean expression evaluates to True, render some html, otherwise,
render some other html.
view : Model -> Html msg
view model =
, article []
[ h1 [] [ text model.title ]
, p []
[ viewEither (model.category == Category.Article)
(\_ -> text "article")
(\_ -> text "something else")
]
]Maybe, the resource has an author. Render what's in the maybe, or nothing.
view : Model -> Html msg
view model =
article []
[ h1 [] [ text "Article" ]
, viewMaybe model.author
(\authorName -> p [] [ text authorName ])
]Render something else if there's nothing in the maybe.
view : Model -> Html msg
view model =
article []
[ h1 [] [ text "Article" ]
, p []
[ viewMaybeWithDefault model.author
(\_ -> text "Anonymous")
(\authorName -> text authorName)
]
]Remove all Html nodes from a String
example :: String
example =
stripHtml "<p>Hola!</p>"
--> "Hola!"This unescapes html unicode characters as well. If parsing fails the original String is returned
Convert a String to Html
This unescapes html unicode characters as well
Truncate a String and append ... if the String is longer than provided length
example : String
example =
truncate 10 "Truncate a String and append `...` if the String is longer than provided length"
--> "Truncate a..."
Render some html if a boolean expression evaluates to
True.