Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# htmltools (development version)

* `htmlDependency()` now includes examples showing dependencies from local
files, URL-based dependencies with script attributes, and package-bundled
dependencies created from a runtime wrapper (#362).

* The `.noWS` documentation now lists `inside` for tags and correctly describes
`outside` for `HTML()` (#303).

Expand Down
42 changes: 42 additions & 0 deletions R/html_dependency.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,48 @@
#' The shape of the `htmlDependency` object is described (in TypeScript code)
#' [here](https://github.com/rstudio/shiny/blob/474f1400/srcts/src/shiny/render.ts#L79-L115).
#'
#' @examples
#' # A dependency from files on disk. The script and stylesheet paths are
#' # relative to the dependency's `src` directory.
#' dir <- tempfile("html-dependency-")
#' dir.create(dir)
#' writeLines("console.log('demo dependency');", file.path(dir, "demo.js"))
#' writeLines(".demo { color: steelblue; }", file.path(dir, "demo.css"))
#'
#' htmlDependency(
#' name = "demo",
#' version = "1.0.0",
#' src = dir,
#' script = "demo.js",
#' stylesheet = "demo.css"
#' )
#'
#' # A dependency loaded from a URL can use `href` and script attributes such as
#' # integrity and crossorigin.
#' htmlDependency(
#' name = "demo-cdn",
#' version = "1.0.0",
#' src = c(href = "https://example.com/demo/1.0.0"),
#' script = list(
#' src = "demo.min.js",
#' integrity = "sha384-...",
#' crossorigin = "anonymous"
#' )
#' )
#'
#' # If dependency files live under a package's inst/ directory, wrap the
#' # dependency in a function and use a relative `src` with `package`.
#' myDependency <- function() {
#' htmlDependency(
#' name = "my-package-assets",
#' version = "1.0.0",
#' src = "www",
#' package = "mypackage",
#' script = "app.js",
#' stylesheet = "app.css"
#' )
#' }
#'
#' @export
htmlDependency <- function(name,
version,
Expand Down
43 changes: 43 additions & 0 deletions man/htmlDependency.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading