Render template strings
(templatel-render-file (path variables &rest opt))
Render template file at PATH with VARIABLES.
Just like with
templatel-render-string,
templates rendered with this function also can’t use {% extends %}
statements. Please refer to the section
Template Environments
to learn how to use the API that enables template inheritance.
Given the HTML template file.html
:
Hi, {{ name }}!
And the following Lisp code:
(templatel-render-file "out.html" ’(("name" . "test")))
When, executed the above code would generate the file ‘out.html‘ with the variable interpolated into the content. e.g.:
Hi, test!
The argument OPT can have the following entries:
- AUTOESCAPE-EXT: list contains which file extensions enable
automatic enabled HTML escaping. In the example above, HTML
entities present in ‘name‘ will be escaped. Notice that the
comparison is case sensitive. Defaults to ’("html" "xml")
.
(templatel-render-string (template variables &rest options))
Render TEMPLATE string with VARIABLES.
This is the simplest way to use templatel, since it only takes
a function call. However, notice that it won’t allow you to
extend other templates because no :importfn
can be passed to
the implicit envoronment created within this function. Please
refer to the next section
Template Environments
to learn how to use the API that enables template inheritance.
The argument OPTIONS can have the following entries:
- AUTOESCAPE: enables automatic HTML entity escaping. Defaults
to
nil
.
(templatel-render-string "Hello, {{ name }}!" ’(("name" . "GNU!")))