Skip to content

Should a template define at least one function? #93

Description

@skaurus

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions