makara
makara copied to clipboard
Breaking: Remove support for mode=json
I think we can eliminate the feature entirely: It's used seldom and when it's used, it's mostly abused. Quoting takes more contextual awareness than a dust helper can give.
Hi @aredridel, Why do you think that mode=json should be removed and not mode=paired?
Thx!
mode=paired probably should be too: what people usually use it for is lists of states and countries, which really can just live in a template.
What makes json a more important target though is that it can't work right -- the quoting rules require more context sensitivity than dust can use, and is just a source of bugs -- possibly security affecting ones.
I agree with you regarding the quoting rules problems but mode=paired/json can be useful with the provide helper.
You can use it to build multiple views (multiple pages) sharing one dust partial. Thus, you can pass the view-related i18n content to the dust partial.
Yeah. I think there are better, simpler, less complicated ways to do those things. And with json in particular, it'll work until it doesn't. And the failure won't be obvious -- it'll be a parse error in the middle of transient state. Extremely hard to debug.
I'd suggest repeating oneself a bit more often instead of introducing that complexity.
A good way could be to keep the mode=paired/json with the @message helper directly and pushing the i18n content into the helper body context (thus not rendering it):
To iterate over i18n keys:
{@message type="content" key="foo.bar" mode="paired" varName="i18n"}
{#i18n}
...
{/i18n}
{/message}
To inject i18n keys in a partial dust template:
{@message type="content" key="foo.bar" mode="json" varName="i18n"}
{>"partials/jumbotron" content=i18n/}
{/message}
Note: The varName parameter describes the namespace for storing the injected i18n content into @message body context.