#' @importFrom rlang abort
abort_glue <- function(..., .sep = "", .envir = parent.frame(),
call. = FALSE, .domain = NULL) {
abort(
glue_null(..., .sep = .sep, .envir = .envir),
call. = call., domain = .domain
)
}
warn_glue <- function(..., .sep = "", .envir = parent.frame(),
call. = FALSE, .domain = NULL) {
warn(
glue_null(..., .sep = .sep, .envir = .envir),
call. = call., domain = .domain
)
}
glubort <- function(header, ..., .envir = parent.frame(), .abort = abort) {
text <- glue(..., .envir = .envir)
if (!is_null(header)) text <- paste0(header, " ", text)
.abort(text)
}
stop_glue <- function(..., .sep = "", .envir = parent.frame(),
call. = FALSE, .domain = NULL) {
stop(
glue_null(..., .sep = .sep, .envir = .envir),
call. = call., domain = .domain
)
}
warning_glue <- function(..., .sep = "", .envir = parent.frame(),
call. = FALSE, .domain = NULL) {
warning(
glue_null(..., .sep = .sep, .envir = .envir),
call. = call., domain = .domain
)
}
message_glue <- function(..., .sep = "", .envir = parent.frame(),
.domain = NULL, .appendLF = TRUE) {
message(
glue_null(..., .sep = .sep, .envir = .envir),
domain = .domain, appendLF = .appendLF
)
}
glue_null <- function(..., .sep = "", .envir = parent.frame()) {
glue::glue(
..., .sep = .sep, .envir = .envir, .transformer = null_transformer
)
}
# This allows to print 'NULL' in `glue()` for code which evaluates in `NULL`
null_transformer <- function(text, envir) {
out <- eval(parse(text = text, keep.source = FALSE), envir)
if (is.null(out)) {
return("NULL")
}
out
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.