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.

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, Nick, that was much simpler!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.