add_files: Create Files

add_js_fileR Documentation

Create Files

Description

These functions create files inside the inst/app folder.

Usage

add_js_file(
  name,
  pkg = get_golem_wd(),
  dir = "inst/app/www",
  open = TRUE,
  dir_create = TRUE,
  with_doc_ready = TRUE,
  template = golem::js_template,
  ...
)

add_js_handler(
  name,
  pkg = get_golem_wd(),
  dir = "inst/app/www",
  open = TRUE,
  dir_create = TRUE,
  template = golem::js_handler_template,
  ...
)

add_js_input_binding(
  name,
  pkg = get_golem_wd(),
  dir = "inst/app/www",
  open = TRUE,
  dir_create = TRUE,
  initialize = FALSE,
  dev = FALSE,
  events = list(name = "click", rate_policy = FALSE)
)

add_js_output_binding(
  name,
  pkg = get_golem_wd(),
  dir = "inst/app/www",
  open = TRUE,
  dir_create = TRUE
)

add_css_file(
  name,
  pkg = get_golem_wd(),
  dir = "inst/app/www",
  open = TRUE,
  dir_create = TRUE,
  template = golem::css_template,
  ...
)

add_sass_file(
  name,
  pkg = get_golem_wd(),
  dir = "inst/app/www",
  open = TRUE,
  dir_create = TRUE,
  template = golem::sass_template,
  ...
)

add_empty_file(
  name,
  pkg = get_golem_wd(),
  dir = "inst/app/www",
  open = TRUE,
  dir_create = TRUE,
  template = golem::empty_template,
  ...
)

add_html_template(
  name = "template.html",
  pkg = get_golem_wd(),
  dir = "inst/app/www",
  open = TRUE,
  dir_create = TRUE
)

add_partial_html_template(
  name = "partial_template.html",
  pkg = get_golem_wd(),
  dir = "inst/app/www",
  open = TRUE,
  dir_create = TRUE
)

add_ui_server_files(pkg = get_golem_wd(), dir = "inst/app", dir_create = TRUE)

Arguments

name

The name of the module.

pkg

Path to the root of the package. Default is get_golem_wd().

dir

Path to the dir where the file while be created.

open

Should the created file be opened?

dir_create

Creates the directory if it doesn't exist, default is TRUE.

with_doc_ready

For JS file - Should the default file include ⁠$( document ).ready()⁠?

template

Function writing in the created file. You may overwrite this with your own template function.

...

Arguments to be passed to the template function.

initialize

For JS file - Whether to add the initialize method. Default to FALSE. Some JavaScript API require to initialize components before using them.

dev

Whether to insert console.log calls in the most important methods of the binding. This is only to help building the input binding. Default is FALSE.

events

List of events to generate event listeners in the subscribe method. For instance, list(name = c("click", "keyup"), rate_policy = c(FALSE, TRUE)). The list contain names and rate policies to apply to each event. If a rate policy is found, the debounce method with a default delay of 250 ms is applied. You may edit manually according to https://shiny.rstudio.com/articles/building-inputs.html

Value

The path to the file, invisibly.

Note

add_ui_server_files will be deprecated in future version of {golem}

See Also

js_template, js_handler_template, and css_template


golem documentation built on Sept. 11, 2024, 7:54 p.m.