R6 method for ExTera: turn autoescaping of HTML on or off.
Autoescaping is on by default.
$autoescape_on()
$autoescape_off()
Examples
tera <- new_engine()
tera$add_string_templates(
"hello-world" = '<p>Hello {{ x }}. This is {{ y }}.</p>',
"hello-world.html" = '<p>Hello {{ x }}. This is {{ y }}.</p>'
)
# not recognized as html
tera$render_to_string(
"hello-world",
x = "&world",
y = "an apostrophe, '"
)
#> [1] "<p>Hello &world. This is an apostrophe, '.</p>"
# html
tera$render_to_string(
"hello-world.html",
x = "&world",
y = "an apostrophe, '"
)
#> [1] "<p>Hello &world. This is an apostrophe, '.</p>"
# turn off autoescape
tera$autoescape_off()
#> ✔ Autoescaping is now off!
tera$render_to_string(
"hello-world.html",
x = "&world",
y = "an apostrophe, '"
)
#> [1] "<p>Hello &world. This is an apostrophe, '.</p>"