Skip to content

Instantly share code, notes, and snippets.

@joshhornby
Created January 17, 2018 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshhornby/a690d46033bf85b7570f5289b8b69510 to your computer and use it in GitHub Desktop.
Save joshhornby/a690d46033bf85b7570f5289b8b69510 to your computer and use it in GitHub Desktop.
view : Model -> Html msg
view model =
renderItemsWithDefault renderList emptyState model.strings
renderList : List String -> Html msg
renderList strings =
ul [] <| List.map (\s -> li [] [ text s ] ) strings
emptyState : Html msg
emptyState =
p [] [ text "No results" ]
renderItemsWithDefault : (List a -> Html msg) -> Html msg -> List a -> Html msg
renderItemsWithDefault f default list =
case list of
[] -> default
list -> f list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment