Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

htmlDependencies

HTML dependency metadata


Description

Gets or sets the HTML dependencies associated with an object (such as a tag).

Usage

htmlDependencies(x)

htmlDependencies(x) <- value

attachDependencies(x, value, append = FALSE)

Arguments

x

An object which has (or should have) HTML dependencies.

value

An HTML dependency, or a list of HTML dependencies.

append

If FALSE (the default), replace any existing dependencies. If TRUE, add the new dependencies to the existing ones.

Details

attachDependencies provides an alternate syntax for setting dependencies. It is similar to local({htmlDependencies(x) <- value; x}), except that if there are any existing dependencies, attachDependencies will add to them, instead of replacing them.

As of htmltools 0.3.4, HTML dependencies can be attached without using attachDependencies. Instead, they can be added inline, like a child object of a tag or tagList.

Examples

# Create a JavaScript dependency
dep <- htmlDependency("jqueryui", "1.11.4", c(href="shared/jqueryui"),
                      script = "jquery-ui.min.js")

# A CSS dependency
htmlDependency(
  "font-awesome", "4.5.0", c(href="shared/font-awesome"),
  stylesheet = "css/font-awesome.min.css"
)

# A few different ways to add the dependency to tag objects:
# Inline as a child of the div()
div("Code here", dep)
# Inline in a tagList
tagList(div("Code here"), dep)
# With attachDependencies
attachDependencies(div("Code here"), dep)

htmltools

Tools for HTML

v0.5.1.1
GPL (>= 2)
Authors
Joe Cheng [aut], Carson Sievert [aut, cre] (<https://orcid.org/0000-0002-4958-2844>), Winston Chang [aut], Yihui Xie [aut], Jeff Allen [aut], RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.