## ----------------------------------------------------------------------------- #| include: false library(shinyelectron) # Read the default webPreferences block from the main.js template so this # article stays in sync with the source. The template uses {{app_slug}} as a # handlebars placeholder; we render it as for readability. read_web_preferences <- function() { path <- system.file("electron/shared/main.js", package = "shinyelectron") lines <- readLines(path) start <- grep("^\\s*webPreferences:\\s*\\{\\s*$", lines)[1] indent <- regmatches(lines[start], regexpr("^\\s*", lines[start])) close_pattern <- paste0("^", indent, "\\},?\\s*$") end <- start + grep(close_pattern, lines[(start + 1):length(lines)])[1] block <- lines[start:end] block <- sub(paste0("^", indent), "", block) block <- gsub("\\{\\{app_slug\\}\\}", "", block) block[length(block)] <- sub(",\\s*$", "", block[length(block)]) block } ## ----------------------------------------------------------------------------- #| echo: false #| results: asis cat(c("```js", read_web_preferences(), "```"), sep = "\n")