rstudio / rmarkdown

Dynamic Documents for R
https://rmarkdown.rstudio.com
GNU General Public License v3.0
2.86k stars 970 forks source link

include script in source page #455

Open thomasbrand opened 9 years ago

thomasbrand commented 9 years ago

I need to include a script in a page. I know the 'includes' option in html_document, but I want to call the script before the head, and not 'in_header', how can I procede ? Thanks!

jjallaire commented 9 years ago

For this you probably just need to create your own template (there's no way to inject code in the head outside of the in_header directive)

On Fri, Jun 19, 2015 at 5:11 AM, thomasbrand notifications@github.com wrote:

I need to include a script in a page. I know the 'includes' option in html_document, but I want to call the script before the head, and not 'in_header', how can I procede ? Thanks!

— Reply to this email directly or view it on GitHub https://github.com/rstudio/rmarkdown/issues/455.

thomasbrand commented 9 years ago

Thanks, but maybe I must be more precise. I work on rmarkdown in a shiny-server. In order to use the iframe-resizer javascript (http://davidjbradshaw.github.io/iframe-resizer/), I have to include the source before the page is executed, so using the 'includes' option in metadata is to late. If I open the html produced by the shiny-server and put by hand the src in the head, it works. Do I need to create a www folder with a new index.html, containing the javascript ? It doesn't seem to work.

thomasbrand commented 9 years ago

I think I have found the problem, which is similar to #457 in a sense. When I knit locally a Rmd file with only in metadata

output: 
  html_document:
    self_contained: false
    keep_md: true
    includes: 
      in_header: "header_iframe_resizer.html"

everything works fine, but when I add runtime: shiny, or put the Rmd file in my shiny-server folder, the script included in "header_iframe_resizer.html" doesn't work.

jjallaire commented 9 years ago

@jmcphers just did some work to discover more resources for us with runtime:shiny. Have you tried this with the very latest rmarkdown from CRAN? (v0.7). @jmcphers Would the work you did pickup scripts referenced in includes as described above?

thomasbrand commented 9 years ago

Sorry but it still doesn't work locally with runtime: shiny even with rmarkdown v0.7 from CRAN.

thomasbrand commented 9 years ago

Sorry to insist on this issue, but I don't know any way to resolve it alone. Is anybody has an idea why runtime: shiny in the metadata modifies the knit in such way that includes does not work properly ? Thanks.