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
It would be useful if the 'lang' template context path is configurable when registering a fluent helper. If I pass a common context object to every template I use fluent with, I could for example promise the lang data can be found at {{ my_context_object.language }} instead of {{ lang }}: handlebars.register_helper("fluent", Box::new(FluentLoader::new(&*LOCALES, "my_context_object.language")));
I know this makes code in this lib a bit more complex, but it definitely will make my project using this library cleaner.
Why would someone want this? Well, I already inserted an object containing lots of common data into the context (including language). I just want it to read that object, instead of having to clone the lang data to another field in the context.
It is one line of code less, for every route in my project (nice). But even nicer... currently if I forget to pass this variable to the 'context!' it will just use the fallback language, and I don't even get a compiler warning! If I forget to pass the common object, it's a lot easier to spot :D
Thanks for reading!
The text was updated successfully, but these errors were encountered:
It would be useful if the 'lang' template context path is configurable when registering a fluent helper. If I pass a common context object to every template I use fluent with, I could for example promise the lang data can be found at
{{ my_context_object.language }}
instead of{{ lang }}
:handlebars.register_helper("fluent", Box::new(FluentLoader::new(&*LOCALES, "my_context_object.language")));
I know this makes code in this lib a bit more complex, but it definitely will make my project using this library cleaner.
Why would someone want this? Well, I already inserted an object containing lots of common data into the context (including language). I just want it to read that object, instead of having to clone the lang data to another field in the context.
It is one line of code less, for every route in my project (nice). But even nicer... currently if I forget to pass this variable to the 'context!' it will just use the fallback language, and I don't even get a compiler warning! If I forget to pass the common object, it's a lot easier to spot :D
Thanks for reading!
The text was updated successfully, but these errors were encountered: