Skip to contents

Sometimes you want to render multiple copies of a template, using different sets of data variables. parse_template() returns an intermediate version of the template, so you can render() repeatedly without re-parsing the template syntax.

Usage

parse_template(.x, .config)

# S3 method for character
parse_template(.x, .config = default_config())

# S3 method for fs_path
parse_template(.x, .config = default_config())

Arguments

.x

The template. Choices:

  • A template string.

  • A path to a template file (use fs::path()).

.config

The engine configuration. The default matches Jinja defaults, but you can use jinjar_config() to customize things like syntax delimiters, whitespace control, and loading auxiliary templates.

Value

A "jinjar_template" object.

See also

Examples

x <- parse_template("Hello {{ name }}!")

render(x, name = "world")
#> [1] "Hello world!"