Open cpsievert opened 1 year ago
FWIW, here's a decent knitr-based solution.
```{r setup, include=FALSE}
library(knitr)
library(htmltools)
render_as_iframe <- function(x, options, ...) {
lbl <- opts_current$get("label")
if (!dir.exists(lbl)) {
dir.create(lbl)
}
file <- file.path(lbl, paste0(lbl, ".html"))
tryCatch(
save_html(x, file),
error = function(e) {
stop("Don't know how to render ", class(x)[[1]], " as an <iframe>")
}
)
include_url(file)
}
plotly::plot_ly()
Currently you need to
save_html()
, thentags$iframe()
, and take care to mount the right directories. It'd be neat if you could just mark a tag with something likeasIFrame()
and it just prints sensibly (similar to{widgetframe}
, which is now deprecated, but works on any tag and in any context).As a first pass on this, it might make sense to use an approach similar to https://github.com/jcheng5/shadowdom (i.e., leverage web components to transform the (document-ified) tag into an iframe on the client and also put it under a personal repo until we have full confidence in it)