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

Cannot provide custom options.data object to template #9431

Closed
bmeurant opened this issue Oct 29, 2014 · 8 comments
Closed

Cannot provide custom options.data object to template #9431

bmeurant opened this issue Oct 29, 2014 · 8 comments
Assignees

Comments

@bmeurant
Copy link
Contributor

Hi, I tried to add formatjs in an Ember app but it uses options.data.intl to store i18n messages (cf. http://formatjs.io/handlebars/#formatMessage) and providing a such object to template seams impossible because View.render defines itself options.data (https://github.com/emberjs/ember.js/blob/v1.8.0/packages/ember-views/lib/views/view.js#L1048)

Can we imagine a clean integration ?

@rwjblue
Copy link
Member

rwjblue commented Oct 29, 2014

In general I would like a nice story with FormatJS. I'll need to dig into more of the literature to see what is actually being done to know if and how we can integrate better.

@bmeurant
Copy link
Contributor Author

Great ! Let us know your plan if you can. Thank you for that.

@ksol
Copy link

ksol commented Nov 21, 2014

Hello,

I ran into the same issue for the same goal (integrating formatjs in an ember-cli addon). Thanks for taking that matter into consideration !

@bmeurant for the time being, how did you work around this limitation ?

@bmeurant
Copy link
Contributor Author

@ksol I did not because it was only a test, not a concrete business need.

I do not see any acceptable work around for now because you will still have to override View.render :-(

@ksol
Copy link

ksol commented Nov 21, 2014

@bmeurant neither do I, and I don't think rewriting the handlebars integration in order to supply the translations in another way is a viable idea.

For the moment, I think I'll stick with ember-18n which seems pretty solid

@froskos
Copy link

froskos commented Dec 4, 2014

Hi there! I've been fighting to integrate Format JS and Ember in the last days and after a hard fight I just found this discussion about the issue.

@bmeurant exactly, at the moment is necessary to extend View.Render, but that only solves the first part of the problem. If you explore it deeper you'll find that whenever the condition that a bound if helper (the one registered by Ember) observes is changed (so that for example a hidden part of the template is now shown), as that does not trigger rendering an Ember.View (which is the common thing unless you write every single content of an if helper as a separate view)... the Format JS-defined helpers called inside that block won't have available the intl object inside the data object. It does not get injected as the Ember.View.Render is not called. Therefore the translations are not available for the helper ... On the other hand I explored Handlebars implementation to see whether there was a feasible way to inject this data by extending some Handlebars default, or maybe overriding a method.. but so far I could only find a nice bunch of chaotic workaround that do not integrate nicely. So you and @ksol were quite right if you took the decision not to keep walking this path. :)

@rwjblue actually I found this thread too, basically the same topic seen from two optics... BTW guys if anyone is already working on this, plz let me know. I will be happy to collaborate in the integration!

@froskos
Copy link

froskos commented Dec 5, 2014

BTW eventually this is going to be the same as

formatjs/handlebars-intl#55

@stefanpenner
Copy link
Member

this API is no more.

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

No branches or pull requests

6 participants