Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Ember.Handlebars.SafeString depreciation thrown with latest ember version. #364

Closed
nullrocket opened this issue Apr 18, 2016 · 9 comments
Closed

Comments

@nullrocket
Copy link
Contributor

There is a reference in compile-template.js throwing a depreciation warning in the latest ember beta.

//addon/utils/i18n/compile-template.js
...
const SafeString = Ember.Handlebars.SafeString;
...

Easy enough to switch to Ember.String.htmlSafe but I'm not sure what that does to the tests

//tests/unit/utils/i18n/default-compiler-test.js
...
  assert.ok(result instanceof Ember.Handlebars.SafeString);
...
@nullrocket
Copy link
Contributor Author

Just now noticed PR #363 missed it somehow.

@jamesarosen
Copy link
Owner

Can you check with the core team about how we should assert that something is a safe-string?

@jamesarosen
Copy link
Owner

@rwjblue suggests

moduleForComponent('asdf', { integration: true });

test('renders html', function(assert) {
  this.render(hbs`{{some-helper}}`);

  assert.equal(this.$('.some-selector-for-html-values-from-helper').length, 1, 'found html from helper');
});

The problem is that we don't have a component in the Ember-I18n test suite to test. We could create a synthetic one in the dummy app and then test it:

moduleForComponent('dummy-component', 't helper', { integration: true });

test('t escapes HTML', function(assert) {
  this.render(hbs`{{t ...}}`);

  ...
});

That's a bit of an awkward workaround, but it very well might work.

@workmanw
Copy link
Contributor

The plan is to undeprecate Ember.Handlebars.SafeString for now and long term to add Ember.String.isHtmlSafe().

Related: emberjs/ember.js#13318 and emberjs/rfcs#139

@rwjblue
Copy link
Contributor

rwjblue commented Apr 18, 2016

@jamesarosen - No component is needed for that snippet. Just a helper, that you invoke from within this.render.

@jamesarosen
Copy link
Owner

How would I get this.render without moduleForComponent?

@workmanw
Copy link
Contributor

I also created a polyfill for the RFC which seeks to add isHtmlSafe. This whole discussion is only like 8 hours old, so I completely understand if you want to let that thing run it's course first. But it would also be an easy option and require little change on the ember-i18n side. ember-string-ishtmlsafe-polyfill.

@rwjblue
Copy link
Contributor

rwjblue commented Apr 19, 2016

@jamesarosen - See https://github.com/aptible/dashboard.aptible.com/blob/master/tests/integration/helpers/eq-test.js. moduleForComponent is a bad name. It has nothing to do with components, it just renders the template snippet you provide.

@jamesarosen
Copy link
Owner

jamesarosen/ember-i18n has been deprecated in favor of ember-intl.

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

No branches or pull requests

4 participants