makara icon indicating copy to clipboard operation
makara copied to clipboard

Breaking: Remove support for mode=json

Open aredridel opened this issue 10 years ago • 6 comments

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.

aredridel avatar Sep 12 '14 20:09 aredridel

Hi @aredridel, Why do you think that mode=json should be removed and not mode=paired?

Thx!

SimonTernoir avatar Oct 05 '15 15:10 SimonTernoir

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.

aredridel avatar Oct 05 '15 15:10 aredridel

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.

aredridel avatar Oct 05 '15 15:10 aredridel

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.

SimonTernoir avatar Oct 05 '15 15:10 SimonTernoir

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.

aredridel avatar Oct 05 '15 17:10 aredridel

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.

SimonTernoir avatar Oct 06 '15 08:10 SimonTernoir