Gets or sets the HTML dependencies associated with an object (such as a tag).
htmlDependencies(x)
htmlDependencies(x) <- value
attachDependencies(x, value, append = FALSE)
Arguments
An object which has (or should have) HTML dependencies.
An HTML dependency, or a list of HTML dependencies.
If FALSE (the default), replace any existing dependencies. If TRUE, add the new dependencies to the existing ones.
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()
.
# 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"
)
#> List of 10
#> $ name : chr "font-awesome"
#> $ version : chr "4.5.0"
#> $ src :List of 1
#> ..$ href: chr "shared/font-awesome"
#> $ meta : NULL
#> $ script : NULL
#> $ stylesheet: chr "css/font-awesome.min.css"
#> $ head : NULL
#> $ attachment: NULL
#> $ package : NULL
#> $ all_files : logi TRUE
#> - attr(*, "class")= chr "html_dependency"
# A few different ways to add the dependency to tag objects:
# Inline as a child of the div()
div("Code here", dep)
#> <div>Code here</div>
# Inline in a tagList
tagList(div("Code here"), dep)
#> <div>Code here</div>
# With attachDependencies
attachDependencies(div("Code here"), dep)
#> <div>Code here</div>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4