Reuse a Template ChunkSource:
Reuse a template from another chunk or file. By calling
in an R chunk or inline R expression, you can reuse a template defined in
another chunk in your document.
Alternatively, you can store the template in a separate file and use
epoxy_use_file() to reuse it. When stored in a file, the template file can
contain YAML front matter (following the same rules as pandoc documents)
with options that should be applied when calling an epoxy function. The
specific function called by
epoxy_use_file() can be set via the
option in the YAML front matter; the default is
A data set
The chunk label, i.e. the human-readable name, of the chunk containing the template string. This chunk should be an
epoxy_htmlor other epoxy-provided chunk type and it must have a label.
epoxy_use_chunk()will apply the options from this chunk to the template, giving preference to arguments in
epoxy_use_chunk()or the chunk options where it is called. See the "Template Options" section for more details.
Arguments passed on to
A transformer function or transformer chain created with
epoxy_transform(). Alternatively, a character vector of epoxy transformer names, e.g.
c("bold", "collapse")or a list of epoxy transformers, e.g.
The opening delimiter around the template variable or expression. Doubling the full delimiter escapes it.
The closing delimiter around the template variable or expression. Doubling the full delimiter escapes it.
A character string used to collapse a vector result into a single value. If
NULL(the default), the result is not collapsed.
Separator used to separate elements.
Environment to evaluate each expression in. Expressions are evaluated from left to right. If
.xis an environment, the expressions are evaluated in that environment and
.enviris ignored. If
NULLis passed, it is equivalent to
Value to replace
NAvalues with. If
NULLmissing values are propagated, that is an
NAresult will cause
NAoutput. Otherwise the value is replaced by the value of
Value to replace NULL values with. If
character()whole output is
NULLall NULL values are dropped (as in
paste0()). Otherwise the value is replaced by the value of
Value to use as the comment character.
Whether to treat single or double quotes, backticks, and comments as regular characters (vs. as syntactic elements), when parsing the expression string. Setting
.literal = TRUEprobably only makes sense in combination with a custom
.transformer, as is the case with
glue_col(). Regard this argument (especially, its name) as experimental.
Whether to trim the input template with
The template file, i.e. a plain text file, containing the template. An
.txtfile extension is recommended. In addition to the template, the file may also contain YAML front matter containing options that are used when rendering the template via
A character string of the rendered template based on the
chunk. The results are marked as
"asis" output so that they are treated
as regular text rather than being displayed as code results.
Or you can even use it inline:
It's hard to believe that Back to the Future Part II was released in 1989.
The same template could also be stored in a file, e.g.
The YAML front matter is used in template files to set options for the
template. You can use the
engine option to choose the epoxy function to be
applied to the template, e.g.
engine: epoxy_html or
engine: epoxy is assumed unless otherwise specified.
When rendering a template,
inherit the options set in a number of different ways. The final template
options are determined in the following order, ranked by importance. Options
set in a higher-ranked location will override options set in a lower-ranked
The arguments passed to
epoxy_use_chunk(), such as
.dataor any arguments passed in the
.... These options always have preference over options set anywhere else.
The chunk options from the chunk where
The chunk options from the template chunk or file. These options typically are relevant to the template itself, such as the engine used or the opening and closing delimiters.
Global knitr chunk options for the document. You can set these with
?knitr::opts_chunkfor more information.