render {jinjar} | R Documentation |
Render a template
Description
Data is passed to a template to render the final document.
Usage
render(.x, ...)
## S3 method for class 'character'
render(.x, ..., .config = default_config())
## S3 method for class 'fs_path'
render(.x, ..., .config = default_config())
## S3 method for class 'jinjar_template'
render(.x, ...)
Arguments
.x |
The template. Choices:
|
... |
< By default, a length-1 vector is passed as a scalar variable. Use |
.config |
The engine configuration. The default matches Jinja defaults,
but you can use |
Value
String containing rendered template.
See Also
-
parse_template()
supports parsing a template once and rendering multiple times with different data variables. -
vignette("template-syntax")
describes how to write templates.
Examples
# pass data as arguments
render("Hello {{ name }}!", name = "world")
# pass length-1 vector as array
render("Hello {{ name.0 }}!", name = I("world"))
# pass data programmatically
params <- list(name = "world")
render("Hello {{ name }}!", !!!params)
# render template file
## Not run:
render(fs::path("template.txt"), name = "world")
## End(Not run)