This module contains some useful functions for parsing and rendering Html
.
viewIf : Basics.Bool -> (() -> Html msg) -> Html msg
Render some html if a boolean expression evaluates to True
.
view : Model -> Html msg
view model =
article []
[ h1 [] [ text model.title ]
, viewIf
(model.category == Category.Article)
(\_ -> p [] [ text "article" ])
]
viewIfNot : Basics.Bool -> (() -> Html msg) -> Html msg
Render some html if a boolean expression evaluates to False
.
viewMaybe : Maybe a -> (a -> Html msg) -> Html msg
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 ])
]
stripHtml : String -> String
Remove all Html nodes from a String
example :: String
example =
stripHtml "<p>Hola!</p>"
--> "Hola!"
This unescapes character entity references as well. If parsing fails the original String is returned
toHtml : String -> List (Html msg)
Convert a String to Html
This unescapes character entity references as well
truncate : Basics.Int -> String -> String
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..."