Learn R Programming

htmltools (version 0.5.1.1)

tagFunction: Tag function

Description

Create 'lazily' rendered HTML [tags] (and/or [htmlDependencies()]).

Usage

tagFunction(func)

Arguments

func

a function with no arguments that returns HTML tags and/or dependencies.

Examples

Run this code
# NOT RUN {
myDivDep <- tagFunction(function() {
  if (isTRUE(getOption("useDep", TRUE))) {
    htmlDependency(
      name = "lazy-dependency",
      version = "1.0", src = ""
    )
  }
})
myDiv <- attachDependencies(div(), myDivDep)
renderTags(myDiv)
withr::with_options(list(useDep = FALSE), renderTags(myDiv))

# }

Run the code above in your browser using DataLab