rstudio/htmltools — pull request #9 by ramnathv (2014-07-24 13:58:34+00:00)
Title: Allow html_print to create selfcontained pages.

This pull request allows html_print to create selfcontained pages. It uses the `base64enc` package to convert js/css assets into data URIs so that the resulting html pages are self contained.

Here is a quick example to test it.

```r
library(htmltools); library(shiny)
mypage = bootstrapPage(
checkboxInput("outliers", "Show outliers", FALSE)
)
attr(mypage, 'selfcontained') <- TRUE
html_print(mypage)
```

This feature is most useful for widgets that create visualizations. Here is an example that illustrates this case. The `selfcontained` function in `htmlwidgets` sets the `selfcontained` attribute to TRUE, and the S3 methods are set up to call `html_print` by default. If you inspect the source of the resulting html page, you will see that the scripts and styles are DataURIs.

```r
# devtools::install_github(c("ramnathv/htmlwidgets", "ramnathv/knob"))
library(htmlwidgets); library(knob)
k1 <- knob('Knob', 20, 0, 100)
selfcontained(k1)
```

This is just a proof-of-concept. I would love to get thoughts/feedback on how best to handle the API.