Skip to content

Commit 5a4985a

Browse files
committed
more work on supporting server: shiny
1 parent bab481a commit 5a4985a

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

R/html_document_base.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,14 @@ html_document_base <- function(theme = NULL,
121121
if (is_bs_theme(theme)) {
122122
theme <- bslib::bs_global_get()
123123
}
124-
bootstrap_deps <- if (is_bs_theme(theme) && is_shiny(runtime)) {
124+
bootstrap_deps <- if (is_bs_theme(theme) && is_shiny(runtime, metadata[["server"]])) {
125125
list(shiny_bootstrap_lib(theme))
126126
} else {
127127
bootstrap_dependencies(theme)
128128
}
129129
format_deps <- append(format_deps, htmltools::resolveDependencies(bootstrap_deps))
130130
}
131-
else if (isTRUE(bootstrap_compatible) && is_shiny(runtime)) {
131+
else if (isTRUE(bootstrap_compatible) && is_shiny(runtime, metadata[["server"]])) {
132132
# If we can add bootstrap for Shiny, do it
133133
format_deps <- append(format_deps, bootstrap_dependencies("bootstrap"))
134134
}

R/render.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ render <- function(input,
576576

577577
# determine our id-prefix (add one if necessary for runtime: shiny)
578578
id_prefix <- id_prefix_from_args(output_format$pandoc$args)
579-
if (!nzchar(id_prefix) && is_shiny(runtime)) {
579+
if (!nzchar(id_prefix) && is_shiny(runtime, front_matter[["server"]])) {
580580
id_prefix <- "section-"
581581
output_format$pandoc$args <- c(output_format$pandoc$args, rbind("--id-prefix", id_prefix))
582582
}

R/shiny.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ run <- function(file = "index.Rmd", dir = dirname(file), default_file = NULL,
9696
} else {
9797
# look for first one that has runtime: shiny
9898
for (rmd in allRmds) {
99-
runtime <- yaml_front_matter(file.path(dir, rmd))$runtime
100-
if (is_shiny(runtime)) {
99+
yaml <- yaml_front_matter(file.path(dir, rmd))
100+
if (is_shiny(yaml$runtime, yaml$server)) {
101101
default_file <- rmd
102102
break
103103
}
@@ -564,8 +564,9 @@ render_delayed <- function(expr) {
564564
quoted = TRUE)
565565
}
566566

567-
is_shiny <- function(runtime) {
568-
!is.null(runtime) && grepl('^shiny', runtime)
567+
is_shiny <- function(runtime, server = NULL) {
568+
(!is.null(runtime) && grepl('^shiny', runtime)) ||
569+
is_shiny_prerendered(runtime, server)
569570
}
570571

571572
is_shiny_classic <- function(runtime) {

0 commit comments

Comments
 (0)