rstudio / htmltools

Tools for HTML generation and output
https://rstudio.github.io/htmltools/
216 stars 70 forks source link

Consider adding `is.shiny.tag()` function #389

Open daattali opened 1 year ago

daattali commented 1 year ago

It's fairly common for me, I'm not sure about others, to want to know whether or not a particular object is a shiny tag. This is usually done as error checking arguments in a function.

I often add the following function to my utils file:

is.shiny.tag <- function(x) {
  inherits(x, "shiny.tag")
}

Would you accept a PR to add this to {htmltools}, or would you prefer not?

cpsievert commented 1 year ago

I agree this is a pain, and would love a PR. Seems like it'd also be useful to have similar is*() functions for tagList(), HTML(), HTMLDependency()?

daattali commented 1 year ago

I can help with tag and tagList. For HTML/dependency I don't feel comfortable writing their is function and their tests.

For tagList, should it be is.tagList?