Should a template define at least one function?
skaurus opened this issue · 0 comments
skaurus commented
Documentation says that template can "contain arbitrary number of functions".
But is it a requirement?
Say I don't need code reuse in my template. I just have some literal text inside {% %}
block, and text of this block contains variables {%s strvar %}
here and loops {% for _, v := range arr %}{%s v %}{% endfor %}
there.
Do I need to wrap this into some function?
If not, what method do I call to get rendered result?
Example:
{%
Some verbatim text of my template. Lorem ipsum maybe.
But then I want to insert some {%s string %}.
And even iterate over a loop:
{% for i, v := arr %}
{% if i < 5 %}{%s v %}{% endif %}
{% endfor %}
The end!
%}
Is this a legal template?