-
Notifications
You must be signed in to change notification settings - Fork 15
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
Object properties #63
Comments
Have you tried using a filter for this? Seems like it might work better than wrapping your properties as objects in the template data. |
I must say I did not yet. |
Although whether or not filters will work as arguments is also a good question. They probably don't :-/ |
At the moment, you'd have to do this in the business layer. In the future (say version 1.0), I'd expect to see parenthesis added to preserve context. So something like this would be possible: {{ "ui.msg.welcome"|i18n(fullname|withKeyName('name')) }} |
Hi (again),
More or less on the same topic as #61, I wonder whether it would be nice to add support for hash properties. A use-case to illustrate this:
where the "ui.msg.welcome" I18N key would typically be defined as:
That is, given a
fullname
property available in the rendering context (data
), make it possible to pass it along through an object.The current parser can't handle that just yet, but thanks to #62, one can workaround this by wrapping the object:
Between those two options, I don't know which one reads better but, altough I have the feeling that the second option is "fine", the wrapping is cumbersome and somehow less standard than the first option where the object is written in the template.
In the simple cases where there is only one variable to pass around, this wrapping can be automated, but if several variables must be merged in the same object (for instance,
{name: fullname, gender: gender, vip: isVIP}
to interpolate a complex sentence), then automation is not an option anymore. It is still possible to manually wrap the object beforehand, but being able to write the object within the template may feel more straightforward.So it basically boils down to template management preferences 🔪
What do you think?
The text was updated successfully, but these errors were encountered: