The render operator used between {{ and }} :
{{ render path }} renders the file at the given path and displays its content. A file rendered with render is called a "partial" because it contains only part of a page. By convention, partial files are stored in a template folder called "partials":
{{ render "/partials/promotion.html" }}
The path to the partial file can also be relative to the file where render is used:
{{ render "../header.html" }}
When a partial file is rendered, its code does not see the variables declared in the file where render is used, nor any other declarations in that file. For this purpose, you should use macros with parameters, for example:
{{ Image("picture.jpg", 400, 500) }}
See macros for details.
Render is a Scriggo operator and as such can be used in expressions, not only between {{ and }}, like any other operator. Its evaluation returns a string. For example, you can assign its result to a variable for later processing:
{% var email = render "email.html" %}
and use it as part of another expression:
{%%
if discount {
show "Offer: " + render "offer.html"
}
%%}
If the file to render does not exist, a compile error occurs and the template file is not executed or applied to the site. If you want to handle the case where the file does not exist without an error, you can use a special assignment form with the render operator:
{% var promo, ok = render "extra.html" %}
In this example, if the "extra.html" file exists, the promo variable will contain its rendered content and the ok variable will be true. If the "extra.html" file does not exist, promo will be an empty string and ok will be false.
Therefore, if you want to render and display a partial file only if it exists, without errors if it does not, you can write:
{% if promo, ok := render "extra.html"; ok %}{{ promo }}{% end if %}