render icon indicating copy to clipboard operation
render copied to clipboard

How to show multi variables in tmpl file?

Open lmquang opened this issue 10 years ago • 2 comments

This is my code: location := Place{} location.region , location.city = getLocation(params["code"]) r.HTML(200, "home/place", location)

When i code : {{.}} , then it shows {abc def } But I wanna show somethings like: My region: {{ .region }} My city : {{ .city }} But i can't. So, can you show me how to do that ? Thank you

lmquang avatar Jan 25 '15 06:01 lmquang

I think lowercase fields will not be displayed as the Go rules defined.

So you first need to change region to Region, then use {{.Region}}.

Hope helps.

unknwon avatar Jan 28 '15 13:01 unknwon

lower case fields are like private, can be used only where they defined, while uppercase - are "exported" and can be used anywhere

avdept avatar May 17 '15 14:05 avdept