Use custom Localizer/Formatter
aight8 opened this issue · comments
Using all the {%s,d,u shortcuts is nice, it would be awesome when I could define my own "Writer", at least for all the basic stuff.
Greater were when I could define an own localizer/formatter object which is passed trough all the render functions.
This would it really easy to pass a localizer/formatter once and then it's propagated down to all other building blocks.
With go2 generics It would be easy. But for now, It must be solved by define a custom type to the parser - so it use those for the basic write operations and also make it accessible directly in the template.
I can also imagine a template syntax which can access the methods more easily (like golang template funcmap). Like:
{%! DoSomething() %}
is translated to call the DoSomething method on the defined object. Because the parser have no clue about the return value, the return value must be printer like {%v ... %}
. Later this could be optimized by on-compile reflection.