| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/template.R |
| 3 |
\name{knit_expand} |
| 4 |
\alias{knit_expand} |
| 5 |
\title{A simple macro preprocessor for templating purposes} |
| 6 |
\usage{ |
| 7 |
knit_expand(file, ..., text = read_utf8(file), delim = c("{{", "}}")) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{file}{The template file.} |
| 11 |
|
| 12 |
\item{...}{A list of variables to be used for the code in the template; note that |
| 13 |
the variables will be searched for in the parent frame as well.} |
| 14 |
|
| 15 |
\item{text}{Character vector of lines of code. An alternative way to specify |
| 16 |
the template code directly. If \code{text} is provided, \code{file} will be ignored.} |
| 17 |
|
| 18 |
\item{delim}{A pair of opening and closing delimiters for the templating tags.} |
| 19 |
} |
| 20 |
\value{ |
| 21 |
A character vector, with the tags evaluated and replaced by their |
| 22 |
values. |
| 23 |
} |
| 24 |
\description{ |
| 25 |
This function expands a template based on the R expressions in \code{{{}}} |
| 26 |
(this tag can be customized by the \code{delim} argument). These expressions |
| 27 |
are extracted, evaluated and replaced by their values in the original |
| 28 |
template. |
| 29 |
} |
| 30 |
\examples{ |
| 31 |
# see the knit_expand vignette |
| 32 |
if (interactive()) browseVignettes(package = "knitr") |
| 33 |
} |
| 34 |
\references{ |
| 35 |
This function was inspired by the pyexpander and m4 |
| 36 |
(\url{http://www.gnu.org/software/m4/}), thanks to Frank Harrell. |
| 37 |
} |