Learn R Programming

templates (version 0.4.0)

tmpl: Template constructors

Description

tmpl is the constructor function for template objects.

Usage

tmpl(.t, ...)

# S3 method for character tmpl(.t, ..., .envir = parent.frame())

# S3 method for formula tmpl(.t, ...)

# S3 method for tmpl tmpl(.t, ...)

# S3 method for function tmpl(.t, ...)

Arguments

.t

something that can be interpreted as template. See defined methods for options.

...

(name = value | name ~ value) name-value expressions passed on to tmplUpdate

.envir

(environment) the environment in which template snippets are evaluated. For formulas and functions their environment is used.

Details

Objects of class tmpl are stored as a character of length one. They can contain 'snippets' to be evaluated. These snippets are identified by an opening {{ and closing }}. The environment in which they are evaluated is stored in the object. They can be further augmented by supplying arguments in ....

See Also

tmplUpdate, tmplEval

Examples

Run this code

tmpl("Hi {{ toupper(a) }}!", a = "there")
tmpl( ~ {y <- {{ a }}}, a ~ x + 1)
tmpl(function(x) {{ a }} + x, a ~ 1)

Run the code above in your browser using DataLab