R/render.r

# These functions borrowed from staticdocs
find_template <- function(name) {
  file.path(inst_path(), "templates", str_c(name, ".html"))
}

#' Render template.
#' 
#' @param name of the template
#' @param data data for the template
#' @param path location to create file.  If \code{""} (the default), 
#'   prints to standard out.
#' @importFrom whisker whisker.render
render_template <- function(name, data, path = "") {
  template <- readLines(find_template(name))
  
  rendered <- whisker.render(template, data)
  cat(rendered, file = path)
}
wch/vtest documentation built on May 4, 2019, 2:02 a.m.