Skip to content

fix #956 improve get_golem_options doc #957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
+ The functions adding files can no longer take a `name` argument that has length() > 1. This used to cause some bugs (#781)
+ The typo in `install.packages()` in 02_dev.R has been corrected (@asiripanich)
+ `add_dockerfile_with_renv()` now works well with uppercase in package name
+ improve `get_golem_options()` documentation
## Internal changes


Expand Down
44 changes: 28 additions & 16 deletions R/with_opt.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,35 +77,47 @@ with_golem_options <- function(
#'
#' # Define and use golem_options
#' if (interactive()) {
#' # 1. Pass parameters to `run_app`
#' # 1. Pass parameters directly to `run_app`
#'
#' # to set default value, edit run_app like this :
#' run_app( title="My Golem App",
#' content = "something" )
#'
#' # 2. Get the values
#' # 2.1 from the UI side
#'
#' h1(get_golem_options("title"))
#'
#' # 2.2 from the server-side
#'
#' output$param <- renderPrint({
#' paste("param content = ", get_golem_options("content"))
#' })
#'
#' output$param_full <- renderPrint({
#' get_golem_options() # list of all golem options as a list.
#' })
#'
#' # 3. If needed, to set default value, edit `run_app` like this :
#'
#' run_app <- function(
#' title = "this",
#' content = "that"
#' title = "this",
#' content = "that",
#' ...
#' ) {
#' with_golem_options(
#' app = shinyApp(
#' ui = app_ui,
#' server = app_server
#' ),
#' golem_opts = list(
#' p1 = p1,
#' p3 = p3
#' title = title,
#' content = content,
#' ...
#' )
#' )
#' }
#'
#' # 2. Get the values from the UI side
#'
#' h1(get_golem_options("title"))
#'
#' # 3. Get the value from the server-side
#'
#' output$param <- renderPrint({
#' paste("param p2 = ", get_golem_options("p2"))
#' })
#'
#'
#' }
#'
get_golem_options <- function(which = NULL) {
Expand Down
44 changes: 28 additions & 16 deletions man/get_golem_options.Rd

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