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

Commit

Permalink
Merge pull request #127 from jamesarosen/warn-on-unquoted
Browse files Browse the repository at this point in the history
{{t}} helper warns if key parameter is unquoted
  • Loading branch information
locks committed Aug 17, 2014
2 parents 83d8591 + 716c4d9 commit 6438437
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@
var tagName = attrs.tagName;
delete attrs.tagName;

warn("Ember.I18n t helper called with unquoted key: %@. In the future, this will be treated as a bound property, not a string literal.".fmt(key), options.types[0] === 'STRING');

var translationView = TranslationView.create({
context: attrs,
translationKey: key,
Expand Down
13 changes: 13 additions & 0 deletions spec/translateHelperSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ describe('{{t}}', function() {
});
});

it('emits a warning on unquoted keys', function() {
var spy = sinon.spy(Ember.Logger, 'warn');

var view = this.renderTemplate('{{t foo.bar}}');

Ember.run(function() {
expect(spy.callCount).to.equal(1);
expect(spy.lastCall.args[0]).to.match(/unquoted/);
expect(spy.lastCall.args[0]).to.match(/foo\.bar/);
expect(view.$().text()).to.equal('A Foobar');
});
});

it('interpolates values', function() {
var view = this.renderTemplate('{{t "bars.all" count="597"}}');

Expand Down

0 comments on commit 6438437

Please sign in to comment.