'Evaluating code in after_body in an rmd file

I have a bunch of rmd files that I'd like to have a common footer, but would like to include some code in these to be evaluated. If I use:

      includes:
          before_body: "../base/banner.html"
          after_body: "../base/footer.rmd"

in a bookdown section, the contents of the footer.rmd are printed, but not evaluated. Is there are way to have my rmd files all include the same rmd file as a footer and have it also evaluate the code in that file?

Ideally, I'd like to be able to knit this to multiple file types (html, docx, and pdf). I know using a child codeblock works, but I'd prefer to not rely on remembering to put that at the end of the document.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source