[go-nuts] Re: Variable scope for text/template

2017-10-08 Thread bep
https://github.com/golang/go/issues/10608 bep fredag 6. oktober 2017 07.22.49 UTC+2 skrev Hein Meling følgende: > > Hi all, > > Please see linked example code. I've been trying set a "global" variable > ($LastName in the example) for use inside a named template (phony in the > example), but th

[go-nuts] Re: Variable scope for text/template

2017-10-07 Thread silviucapota
Hein, you can try passing a function to the template. That is, a function which de-normalizes your person struct into an ad-hoc Num + Name record See here: https://play.golang.org/p/1XIIO-0lcu Cheers Silviu On Friday, 6 October 2017 01:22:49 UTC-4, Hein Meling wrote: > > Hi all, > > Please see

[go-nuts] Re: Variable scope for text/template

2017-10-07 Thread Simon Ritchie
AFAIK a template can only access the structure that's passed to to it. It can't get at any of the other variables of the Go function that executes it, global or local. All it can do is render the data in the structure that's passed to it. On Friday, October 6, 2017 at 6:22:49 AM UTC+1, Hein M