render
render copied to clipboard
How to show multi variables in tmpl file?
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
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.
lower case fields are like private, can be used only where they defined, while uppercase - are "exported" and can be used anywhere