-
Notifications
You must be signed in to change notification settings - Fork 15
Description
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:
# data
fullname: @user.fullname() # for instance ^^
# template
<span class="greeting">{{ i18n "ui.msg.welcome" {name: fullname} }}</span>where the "ui.msg.welcome" I18N key would typically be defined as:
# en.coffee
ui:
msg:
welcome: "Welcome %{name}"
# fr.coffee
ui:
msg:
welcome: "Bienvenue %{name}"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:
# data
fullname: {fullname: @user.fullname()}
# template
<span class="greeting">{{ i18n "ui.msg.welcome" fullname }}</span>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?