shiyanhui / hero

A handy, fast and powerful go template engine.
https://shiyanhui.github.io/hero
Other
1.57k stars 98 forks source link

Best way to handle Global Static Values #50

Closed speedwheel closed 6 years ago

speedwheel commented 6 years ago

Let's say we have a struct with some global static values and we have to send this values to all the pages, should we include this struct on each func? for example:

template.User(GlobalStatic, UserData buffer) template.Order(GlobalStatic, OrderData buffer) template.Product(GlobalStatic, ProductData buffer) etc...

It's this the right way?

shiyanhui commented 6 years ago

You can expose that struct via package and access it via package in the template. Just like the you do in golang.

speedwheel commented 6 years ago

Your are right, thanks!

speedwheel commented 6 years ago

What if I have a global value that is dynamic? for example some user session values that I want to send in all the templates?