#' @title Create a new Stimulus Controller
#'
#' @description
#' Creates a template at the destination directory with the specific name.
#'
#' @param name (str) stimulus controller name
#' @param dir (dir) directory to save it in
#'
#' @family Stimulus
#'
#' @export
ss_use_controller <- function(name, dir = ".") {
assert_string(name)
assert_directory_exists(dir)
controller_path <- path(dir, paste0(to_snake_case(name), "_controller.js"))
file_copy(pkg_inst("templates", "controller.js"), controller_path)
if (interactive()) file.edit(controller_path) # nocov
return(controller_path)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.