Error in case of nested for loops I have a comment section with comments and subcomments. A comment relates directly to the blog post while a subcomment relates to a comment.

Now, I have the following problem on the entry page: Showing the comments only is not a problem:

{% for comment in craft.entries({
    section: comments,
    relatedTo: { targetElement: entry, field: "relentry" },
    order:     "sortOrder",
    limit:     null
}) %}
    &lt;p&gt;X&lt;/p&gt;
{% endfor %}


But when I insert the subcomments, I get the error message Unexpected "}":

{% for comment in craft.entries({
    section: comments,
    relatedTo: { targetElement: entry, field: "relentry" },
    order:     "sortOrder",
    limit:     null
}) %}
    &lt;p&gt;X&lt;/p&gt;
    {% for subcomment in craft.entries({
        section: comments,
        relatedTo: { targetElement: comment, field: "relentry" },
        order:     "sortOrder",
        limit:     null
    }) %}
        &lt;p&gt;Y&lt;/p&gt;
    {% endfor % }
{% endfor %}


Thank you very much for your help!
It's probably your second-from-last line:

{% endfor % }


should be:

{% endfor %}