In the context of a Shiny application, I'm trying to display warnings thrown by some call as an HTML list.
I could get all warnings as a character vector thanks to this answer, and I'm now actually building the HTML list.
The easiest way I could come up with is this code:
warns = c("warning 1", "warning 2", "warning 3", "warning 4")
paste0("<ul><li>", paste0(warns, collapse = "</li><li>"), "</li></ul>") %>% HTML
Inside shiny::renderUI
, this code outputs well, but it is not very clean, and even after thorough testing I still find it somehow error-prone.
Therefore, I'd like to use the package htmltools to build the list, as it seems to be the recommended way of writing HTML with R.
However, tags$li
can only handle strings and not character vectors, and tags$ul
uses the ellipsis instead of list or vectors so even using loops I couldn't build my list.
What is the best way to build an HTML list using htmltools
?