Skip to content
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

feat: Add warning to code chunk about embed-resources #55

Merged
merged 1 commit into from
Sep 27, 2024

Conversation

gadenbuie
Copy link
Collaborator

@gadenbuie gadenbuie commented Jul 12, 2024

For #12

When shinylive is used with embed-resources: true, the original code chunk is shown in full instead of the shinylive app.

So we can add some warning code to the top of the code chunk that only shows up when shinylive fails to load. The top of the code chunk always contains the chunk options, so we need to use the same syntax:

#| '!! shinylive warning !!': |
#|   shinylive does not work in self-contained HTML documents.
#|   Please set `embed-resources: false` in your metadata.

Hopefully this gives enough information to the person with the broken output to figure out what's going wrong.

Test Document

I put this in _dev/issues/issue-12/issue-12.qmd.

---
title: "Shinylive with embed-resources: true"
format: 
  html:
    embed-resources: true
filters:
  - ../../../_extensions/quarto-ext/shinylive/shinylive.lua
---

```{shinylive-r}
#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400
## file: app.R
library(shiny)

ui <- fluidPage(
  titlePanel("Hello Shiny!")
)

server <- function(input, output) {

}

# Create Shiny app ----
shinyApp(ui = ui, server = server)
```
embed-resources: true embed-resources: false
image image

@gadenbuie gadenbuie requested a review from schloerke July 12, 2024 15:34
@gadenbuie gadenbuie merged commit d93c9f2 into main Sep 27, 2024
2 checks passed
@gadenbuie gadenbuie deleted the feat/warn-embed-resources-true branch September 27, 2024 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants