Skip to content
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

Breaking: Remove support for mode=json #53

Open
aredridel opened this issue Sep 12, 2014 · 6 comments
Open

Breaking: Remove support for mode=json #53

aredridel opened this issue Sep 12, 2014 · 6 comments

Comments

@aredridel
Copy link
Contributor

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.

@SimonTernoir
Copy link

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

Thx!

@aredridel
Copy link
Contributor Author

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
Copy link
Contributor Author

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.

@SimonTernoir
Copy link

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.

@aredridel
Copy link
Contributor Author

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.

@SimonTernoir
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants