Can't make nested if or for loops in template

{{template "base" .}}
{{define "main"}}
    {{range .FlashMessages}}
        <div class="alert alert-danger">{{.}}</div>
    {{end}}
{{end}}

However, this code gives me “not found 404” in the html template, my guessing is that the {{end}} statement for the for/loop ended the {{define “main”}} instead of ending the for loop. If I’m correct then is there a fix for that?
in Django I can directly specifiy what this {{end}} refers to ({% endblock main %} {% endif %} {% endfor %} etc…)

And if this wasn’t the error, Then what?! I’m using Gorilla/sessions and note that when i write {{.}} alone it gives me the flash message i wanted

On a first glance I can’t see a problem with the template, can you perhaps create a minimal example on the playground that tries to render the template?

Just found out that i was using gorilla session flash messages in a wrong way, sorry for that i will close the question. Oh i can’t…

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.