0

I'd like to create some .rhtml files with static HTML included on those. Think of some pages for a class with a common disclaimer included in the generated HTML files. I don't want to have to change all RHTML files with the disclaimer, therefore the idea of including a external HTML-only, no R snippet.

I've checked the answer here but it seems overly complicated for what I want.

My disclaimer looks like:

We don't need no stinking disclaimers.

and I would like to include it in the .rhtml file with something like

<!--begin.rcode echo=FALSE
knit_child('_about.Rhtml')
end.rcode-->

In the resulting .html file I get the results of evaluation of _about.Rhtml but not the contents.

One thing that works is create the HTML snippet as plain HTML and in the main .Rhtml do

<!--begin.rcode echo=FALSE,results='asis'
writeLines(readLines('_about.Rhtml'))
end.rcode-->

This works, but is there a simple/better/more flexible way?

Please advise. I am using RStudio. Thanks.

Community
  • 1
  • 1
Rafael Santos
  • 463
  • 5
  • 16

1 Answers1

1

It's probably easiest to use the child chunk option like this:

<!--begin.rcode child="disclaimer.html"
-->

You can just call the file whatever.html rather than .rhtml.

Nick Kennedy
  • 12,510
  • 2
  • 30
  • 52