You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The way to use an instance of the structure is to add it to a Context:
ctx:=Context{
"mystruct": S
}
And the way to use it in a template is to access the struct members using the Go convention: variables starting with an uppercase letter are exported:
Hello {{ mystruct.Name }}. This is number {{ mystruct.Number }}.
Which works ok, but can be a bit ugly when switching from lowercase names to uppercase. Why not introduce a Go struct tag which renames fields for use in Pongo2? Something like this:
Assuming this struct:
The way to use an instance of the structure is to add it to a Context:
And the way to use it in a template is to access the struct members using the Go convention: variables starting with an uppercase letter are exported:
Which works ok, but can be a bit ugly when switching from lowercase names to uppercase. Why not introduce a Go struct tag which renames fields for use in Pongo2? Something like this:
This would allow more flexibility and consistency in templates by writing:
The text was updated successfully, but these errors were encountered: