The show instruction followed by an expression evaluates it and displays its result:
{% show 5 + 2 %}
{% show price %}
7
€ 29,99
A show instruction can also be written as follows:
{{ 5 + 2 }}
{{ price }}
7
€ 29,99
This second form is the most common because it is simpler to write and read, but you can use either form interchangeably.
Inside {%% and %%}, the show instruction can be used as follows:
{%%
var value = 55
if value < 100 {
show value
} else {
show "too large"
}
%%}
55
{% show expr %}, where expr is a string literal, does not display the string but renders the file with the given path.
Therefore {% show "header.html" %} is equivalent to {{ render "header.html" }}. Its use is deprecated and it is preferable to use render.
The show instruction displays the evaluation of the expression differently based on the context where it is used:
{% var greeting = "hello" %}
<div>{{ greeting }}</div>
<script>
var a = {{ greeting }};
var b = '{{ greeting }} world';
</script><div>hello</div>
<script>
var a = "hello";
var b = 'hello world';
</script>