Skip to content

Commit

Permalink
add includeShinyjs param to runcode construct, to make it a bit e…
Browse files Browse the repository at this point in the history
…asier to call
  • Loading branch information
daattali committed Oct 15, 2016
1 parent 2d079d1 commit bcc9f38
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: shinyjs
Title: Easily Improve the User Experience of Your Shiny Apps in Seconds
Version: 0.7.9003
Version: 0.7.9004
Authors@R: person("Dean", "Attali", email = "[email protected]",
role = c("aut", "cre"))
Description: Perform common useful JavaScript operations in Shiny apps that will
Expand Down
16 changes: 13 additions & 3 deletions R/runcode.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
#' code on-demand. This construct provides your app with a text input where you
#' can enter any R code and run it immediately.\cr\cr
#' This can be useful for testing
#' and while developing an app locally, but it \emph{should not be included in
#' and while developing an app locally, but it \strong{should not be included in
#' an app that is accessible to other people}, as letting others run arbitrary R
#' code can open you up to security attacks.\cr\cr
#' To use this construct, you must add a call to \code{runcodeUI()} in the UI
#' of your app, and a call to \code{runcodeServer()} in the server function. You
#' also need to initialize shinyjs with a call to \code{useShinyjs()}.
#' also need to initialize shinyjs with a call to \code{useShinyjs()} in the UI.
#'
#' @note You can only have one \code{runcode} construct in your shiny app.
#' Calling this function multiple times within the same app will result in
#' unpredictable behaviour.
#'
#' @param code The initial R code to show in the text input when the app loads
#' @param type One of \code{"text"} (default) or \code{"textarea"}. When using
Expand All @@ -20,6 +24,9 @@
#' @param width The width of the text or textarea input
#' @param height The height of the textarea input (only applicable when
#' \code{type="textarea"})
#' @param includeShinyjs Set this to \code{TRUE} only if your app does not have
#' a call to \code{useShinyjs()}. If you are already calling \code{useShinyjs()}
#' in your app, do not use this parameter.
#' @seealso \code{\link[shinyjs]{useShinyjs}}
#' @examples
#' if (interactive()) {
Expand All @@ -42,11 +49,14 @@
runcodeUI <- function(code = "",
type = c("text", "textarea"),
width = NULL,
height = NULL) {
height = NULL,
includeShinyjs = FALSE) {
type <- match.arg(type)
placeholder <- "Enter R code"

shiny::singleton(shiny::tagList(
if (includeShinyjs)
useShinyjs(),
if(type == "text")
shiny::textInput(
"runcode_expr", label = NULL, value = code,
Expand Down
15 changes: 12 additions & 3 deletions man/runcode.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bcc9f38

Please sign in to comment.