Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use custom Localizer/Formatter #81

Open
aight8 opened this issue Dec 3, 2020 · 0 comments
Open

Use custom Localizer/Formatter #81

aight8 opened this issue Dec 3, 2020 · 0 comments

Comments

@aight8
Copy link

aight8 commented Dec 3, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant