mirror of
https://github.com/rstudio/shiny.git
synced 2026-01-11 16:08:19 -05:00
Compare commits
7 Commits
dynamicJsx
...
testServer
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2ae14ca5a | ||
|
|
4b87aa3252 | ||
|
|
d0417c75d6 | ||
|
|
00998b3e14 | ||
|
|
f013fcb5fd | ||
|
|
45f1e5fe50 | ||
|
|
d7feddb131 |
@@ -354,3 +354,4 @@ importFrom(htmltools,validateCssUnit)
|
||||
importFrom(htmltools,withTags)
|
||||
importFrom(promises,"%...!%")
|
||||
importFrom(promises,"%...>%")
|
||||
importFrom(rlang,env_clone)
|
||||
|
||||
@@ -1,13 +1,31 @@
|
||||
# Create a "data mask" suitable for passing to rlang::eval_tidy. Bindings in
|
||||
# `env` and bindings in the parent of `env` are merged into a single named list.
|
||||
# Bindings in `env` take precedence over bindings in the parent of `env`.
|
||||
#' @noRd
|
||||
makeMask <- function(env) {
|
||||
stopifnot(length(rlang::env_parents(env)) > 1)
|
||||
child <- as.list(env)
|
||||
parent <- as.list(rlang::env_parent(env))
|
||||
parent_only <- setdiff(names(parent), names(child))
|
||||
append(child, parent[parent_only])
|
||||
# Constructs an rlang::eval_tidy() data mask with semantics appropriate for use
|
||||
# in testServer().
|
||||
#
|
||||
# env is assumed to be session$env, or the environment captured by invoking a
|
||||
# module under test.
|
||||
#
|
||||
# Consider the following module definition and its enclosing environment:
|
||||
#
|
||||
# x <- 1
|
||||
# m <- function(id) {
|
||||
# y <- 2
|
||||
# moduleServer(id, function(input, output, session){
|
||||
# z <- 3
|
||||
# })
|
||||
# }
|
||||
#
|
||||
# The data mask returned by this function should include z, session,
|
||||
# output, input, y, and id, but *not* x. Definitions not masked are
|
||||
# resolved in the environment in which testServer() is called.
|
||||
#
|
||||
# env is cloned because rlang::new_data_mask() mutates the parent of its `top`
|
||||
# argument.
|
||||
#' @importFrom rlang env_clone
|
||||
buildMask <- function(env) {
|
||||
if (identical(parent.env(env), emptyenv()))
|
||||
stop("env must have a non-empty parent")
|
||||
clone <- env_clone(env, env_clone(parent.env(env), emptyenv()))
|
||||
rlang::new_data_mask(clone, parent.env(clone))
|
||||
}
|
||||
|
||||
#' @noRd
|
||||
@@ -112,7 +130,7 @@ testServer <- function(app, expr, ...) {
|
||||
withReactiveDomain(
|
||||
session,
|
||||
withr::with_options(list(`shiny.allowoutputreads` = TRUE), {
|
||||
rlang::eval_tidy(quosure, makeMask(session$env), rlang::caller_env())
|
||||
rlang::eval_tidy(quosure, buildMask(session$env), rlang::caller_env())
|
||||
})
|
||||
)
|
||||
)
|
||||
|
||||
@@ -4,29 +4,34 @@
|
||||
\alias{markdown}
|
||||
\title{Insert inline Markdown}
|
||||
\usage{
|
||||
markdown(mds, extensions = TRUE, ...)
|
||||
markdown(mds, extensions = TRUE, .noWS = NULL, ...)
|
||||
}
|
||||
\arguments{
|
||||
\item{mds}{A character vector of Markdown source to convert to HTML. If the
|
||||
vector has more than one element, resulting HTML is concatenated.}
|
||||
vector has more than one element, a single-element character vector of
|
||||
concatenated HTML is returned.}
|
||||
|
||||
\item{extensions}{Enable Github syntax extensions, defaults to \code{TRUE}.}
|
||||
\item{extensions}{Enable Github syntax extensions; defaults to \code{TRUE}.}
|
||||
|
||||
\item{.noWS}{Character vector used to omit some of the whitespace that would
|
||||
normally be written around generated HTML. Valid options include \code{before},
|
||||
\code{after}, and \code{outside} (equivalent to \code{before} and \code{end}).}
|
||||
|
||||
\item{...}{Additional arguments to pass to \code{\link[commonmark:markdown_html]{commonmark::markdown_html()}}.
|
||||
These arguments are \emph{\link[rlang:dyn-dots]{dynamic}}.}
|
||||
}
|
||||
\value{
|
||||
an \code{html}-classed character vector of rendered HTML
|
||||
a character vector marked as HTML.
|
||||
}
|
||||
\description{
|
||||
This function accepts a character vector of
|
||||
\href{https://en.wikipedia.org/wiki/Markdown}{Markdown}-syntax text and renders
|
||||
it to HTML that may be included in a UI.
|
||||
This function accepts
|
||||
\href{https://en.wikipedia.org/wiki/Markdown}{Markdown}-syntax text and returns
|
||||
HTML that may be included in Shiny UIs.
|
||||
}
|
||||
\details{
|
||||
Prior to interpretation as Markdown, leading whitespace is trimmed from text
|
||||
with \code{\link[glue:trim]{glue::trim()}}. This makes it possible to insert Markdown and for it to
|
||||
be processed correctly even when the call to \code{markdown()} is indented.
|
||||
Leading whitespace is trimmed from Markdown text with \code{\link[glue:trim]{glue::trim()}}.
|
||||
Whitespace trimming ensures Markdown is processed correctly even when the
|
||||
call to \code{markdown()} is indented within surrounding R code.
|
||||
|
||||
By default, \link[commonmark:extensions]{Github extensions} are enabled, but this
|
||||
can be disabled by passing \code{extensions = FALSE}.
|
||||
|
||||
Reference in New Issue
Block a user