Females:
Sofia
Anna
On 10/10/2013 8:54 PM, "Accipiter Nisus" <acci...@gmail.com> wrote:
>
> Hi,
>
> What are the reasons why it is not possible to assign a new value to an already initiated variable in the text/template package?
>
Templates aren't the place for doing complex logic. Do it before you pass the data to the template.
> {{$hasFemales := 0}}
> {{range .}}{{if eq .sex "F"}}{{$hasFemales = 1}}{{end}}{{end}}
> {{if $hasFemale}}Female:{{end}}
>
> Example: http://play.golang.org/p/T-Ekx7n9YQ
You can easily count the females before you pass the slice to the template and pass that in too.
Templates aren't the place for doing complex logic. Do it before you pass the data to the template.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
{{$deprecated := false}} {{range $depre_audit := $depre_audits}} {{if eq $audit_name $depre_audit}} {{$deprecated := true}} ------> this line doesn't work beyond end <span class="audit_name_chart">{{$audit_name}} - deprecated</span> {{end}} {{end}} {{if not $deprecated}} <span class="audit_name_chart">{{$audit_name}}</span> {{end}}