[go-nuts] Dynamic template data from yaml

2023-10-14 Thread Tong Sun
Please take a look at https://go.dev/play/p/dTDR50dtHB0 I want to - define my template data dynamically from yaml - and export the yaml data if they are unexported I.e., for the following code: t := template.New("") t, err = t.Parse("It's {{.A}} {{.B.C}}!\n") if err != nil { log.Fatalf("error:

Re: [go-nuts] Dynamic template data from yaml

2023-10-14 Thread 'Dan Kortschak' via golang-nuts
On Sat, 2023-10-14 at 09:33 -0700, Tong Sun wrote: > Please take a look at  > https://go.dev/play/p/dTDR50dtHB0 > > I want to > > - define my template data dynamically from yaml > - and export the yaml data if they are unexported > > I.e., for the following code: > > t := template.New("")

Re: [go-nuts] Dynamic template data from yaml

2023-10-14 Thread Tong Sun
On Saturday, October 14, 2023 at 3:47:54 PM UTC-4 Dan Kortschak wrote: On Sat, 2023-10-14 at 09:33 -0700, Tong Sun wrote: > Please take a look at > https://go.dev/play/p/dTDR50dtHB0 > > I want to > > - define my template data dynamically from yaml > - and export the yaml data if they are

Re: [go-nuts] Dynamic template data from yaml

2023-10-14 Thread 'Dan Kortschak' via golang-nuts
On Sat, 2023-10-14 at 13:15 -0700, Tong Sun wrote: > Hmm... somehow I had the impression that only the exported fields can > be used in template as variables. > > Is that a wrong impression or things have changed? You are indexing into a map so so the notion of fields is not relevant. -- You re