martini-contrib / render

Martini middleware/handler for easily rendering serialized JSON, XML, and HTML template responses.
MIT License
245 stars 57 forks source link

How to show multi variables in tmpl file? #44

Open lmquang opened 9 years ago

lmquang commented 9 years ago

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

unknwon commented 9 years ago

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.

avdept commented 9 years ago

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