This is a short demo of how to use brew and knitr in combination with each other to get the best of the templating facilities in brew and the literate programming functions in knitr. The main idea is to write a function brew_knit
# Preprocess template using brew and then run knit on the output
brew_knit <- function(template, params, ...){
brew::brew(template, envir = list2env(params))
input = gsub(".Rnwe", '.Rnw', template)
knitr::knit(input)
}