blue-jay / blueprint

Blueprint for your next web application in Go.
https://blue-jay.github.io/
MIT License
482 stars 77 forks source link

Foreach in a view ? #76

Closed aquint-g closed 6 years ago

aquint-g commented 6 years ago

I'm sure i'm missing something but i can't find a way to parse easily my arrays in a view.

For instance i want to list every users registered on my webapp. I'm able to get them form the database, push them to the view.. But I'm only able to print a JSON of the items.

Isn't there a way to do something like a foreach in tpml files ?

Thanks in advance

josephspurrier commented 6 years ago

Yes, you can loop through the items like this:

https://github.com/blue-jay/blueprint/blob/master/view/note/index.tmpl#L13

{{range $n := .items}}
    <p>{{.Name}}</p>
{{end}}