Once a template has been parsed, it can be printed with color highlighting of the templating blocks.
Usage
# S3 method for jinjar_template
print(x, ..., n = 10)
Arguments
- x
A parsed template (use
parse_template()
).- ...
These dots are for future extensions and must be empty.
- n
Number of lines to show. If
Inf
, will print all lines. Default:10
.
Examples
input <- '<!DOCTYPE html>
<html lang="en">
<head>
<title>{{ title }}</title>
</head>
<body>
<ul id="navigation">
{% for item in navigation -%}
<li><a href="{{ item.href }}">{{ item.caption }}</a></li>
{% endfor -%}
</ul>
{# a comment #}
</body>
</html>'
x <- parse_template(input)
print(x)
#> <!DOCTYPE html>
#> <html lang="en">
#> <head>
#> <title>{{ title }}</title>
#> </head>
#> <body>
#> <ul id="navigation">
#> {% for item in navigation -%}
#> <li><a href="{{ item.href }}">{{ item.caption }}</a></li>
#> {% endfor -%}
#> ℹ … with 4 more lines
print(x, n = Inf)
#> <!DOCTYPE html>
#> <html lang="en">
#> <head>
#> <title>{{ title }}</title>
#> </head>
#> <body>
#> <ul id="navigation">
#> {% for item in navigation -%}
#> <li><a href="{{ item.href }}">{{ item.caption }}</a></li>
#> {% endfor -%}
#> </ul>
#> {# a comment #}
#> </body>
#> </html>