It seems that return does not work the way I would expect it to. For instance in JavaScript a return stops execution of whatever the script is running.
Apparently this does not work this way in Go templates?
{{ return }}
{{ $context := .context }}
{{- if eq "home" $context.Kind -}}
<script src="something"></script>
{{ end }}
(lazy sample, sorry, I wanted to just keep a partial in line but remove what it did for a bit). This will still print the script line.
So, is this a feature or a bug? I can twist my mind around a return being at any arbitrary position and then doing some more stuff, but I think that would be something that needs to be mentioned in the docs.
Also, assuming I return a value, will the returned value be the one at the position of the return or the value that it has at the end of the template (if I modify it further)?
That is indeed what is expected. What @davidsneighbour has stumbled on is a case where actual behavior is not necessarily what one would expect if one does something other than intended ā and it doesnāt throw an error when one does the āstrangeā thing.
I have. Have you understood my irritation coming from different programming languages where the return partial is not enforced at the end of a routine but results in immediate return?
If āmyā return in the first line is basically false, I wonder why itās ignored instead of ābemoanedā.
Have you understood my irritation coming from me spending 10 hours of my vacation time to implement basic return support in partials, yet you expect me to spend 100 hours to get it in line with your expectations?
Letās not take this furtherā¦ For the new documentation I would wish that cursive would be more visible. Itās probably just a accessibility issue: