R/utils.R

Defines functions tick_or_cross has_cli extract_path clean_hash router_ns

# Remove symbols from the router path for namespacing
router_ns <- function(namespace) {
  gsub("[^[:alnum:]]", "__", namespace)
}

clean_hash <- function(hash) {
  paste0("#!/", sub("^[#!/]*", "", hash))
}

extract_path <- function(hash) {
  sub("^/+|/$", "", sub("\\?.*$", "", sub("^#!", "", hash)))
}

has_cli <- function() {
  requireNamespace("cli", quietly = TRUE)
}

tick_or_cross <- function(x, msg) {
  if (x) {
    cli::cli_alert_success(msg)
  } else {
    cli::cli_alert_danger(msg)
  }
}
gorcha/shinypages documentation built on June 29, 2022, 4:38 a.m.