R/turbo-link.R

Defines functions turbo_link

Documented in turbo_link

#' @title Turbo Link
#'
#' @description A Link that targets specific Turbo visits
#'
#' @param action (str) advance (add history) or replace (don't add history)
#' @param frame  (str) targeted frame (can be "_top" for whole page) or NULL
#'                     for the ancestor turbo frame.
#' @param tag    (fun) target function to generate tag
#' @param ...    (tag) content of the page
#'
#' @family Turbo
#' @export
turbo_link <- function(...,
                       action = c("advance", "replace"),
                       frame = NULL,
                       tag = tags$a) {

  action <- match_arg(action)
  assert_function(tag)

  tag(...) %>%
    add_data(`turbo-action` = action, `turbo-frame` = frame) %>%
    add_class("turbo_link")

}
tjpalanca/hotwire.R documentation built on Dec. 23, 2021, 10:59 a.m.