Skip to content

Commit a3d268d

Browse files
committed
[BUGFIX release] Deprecate Ember.Handlebars.registerHelper.
1 parent 63da31f commit a3d268d

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed

packages/ember-htmlbars/lib/compat/helper.js

+6
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ HandlebarsCompatibleHelper.prototype = {
109109
};
110110

111111
export function registerHandlebarsCompatibleHelper(name, value) {
112+
Ember.deprecate(
113+
'Ember.Handlebars.registerHelper is deprecated, please refactor to Ember.Helper.helper.',
114+
false,
115+
{ id: 'ember-htmlbars.handlebars-register-helper', until: '2.0.0' }
116+
);
117+
112118
if (value && value.isLegacyViewHelper) {
113119
registerKeyword(name, function(morph, env, scope, params, hash, template, inverse, visitor) {
114120
Ember.assert('You can only pass attributes (such as name=value) not bare ' +

packages/ember-htmlbars/tests/compat/helper_test.js

+21-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
registerHandlebarsCompatibleHelper
2+
registerHandlebarsCompatibleHelper as registerHelper
33
} from 'ember-htmlbars/compat/helper';
44

55
import EmberView from 'ember-views/views/view';
@@ -18,6 +18,12 @@ import viewKeyword from 'ember-htmlbars/keywords/view';
1818

1919
var view, registry, container, originalViewKeyword;
2020

21+
function registerHandlebarsCompatibleHelper() {
22+
expectDeprecation('Ember.Handlebars.registerHelper is deprecated, please refactor to Ember.Helper.helper.');
23+
24+
return registerHelper(...arguments);
25+
}
26+
2127
QUnit.module('ember-htmlbars: compat - Handlebars compatible helpers', {
2228
setup() {
2329
originalViewKeyword = registerKeyword('view', viewKeyword);
@@ -40,7 +46,7 @@ QUnit.module('ember-htmlbars: compat - Handlebars compatible helpers', {
4046
});
4147

4248
QUnit.test('wraps provided function so that original path params are provided to the helper', function() {
43-
expect(2);
49+
expect(3);
4450

4551
function someHelper(param1, param2, options) {
4652
equal(param1, 'blammo');
@@ -60,7 +66,7 @@ QUnit.test('wraps provided function so that original path params are provided to
6066
});
6167

6268
QUnit.test('combines `env` and `options` for the wrapped helper', function() {
63-
expect(1);
69+
expect(2);
6470

6571
function someHelper(options) {
6672
equal(options.data.view, view);
@@ -79,7 +85,7 @@ QUnit.test('combines `env` and `options` for the wrapped helper', function() {
7985
});
8086

8187
QUnit.test('combines `env` and `options` for the wrapped helper', function() {
82-
expect(1);
88+
expect(2);
8389

8490
function someHelper(options) {
8591
equal(options.data.view, view);
@@ -122,7 +128,7 @@ QUnit.test('has the correct options.data.view within a components layout', funct
122128
});
123129

124130
QUnit.test('adds `hash` into options `options` for the wrapped helper', function() {
125-
expect(1);
131+
expect(2);
126132

127133
function someHelper(options) {
128134
equal(options.hash.bestFriend, 'Jacquie');
@@ -141,7 +147,7 @@ QUnit.test('adds `hash` into options `options` for the wrapped helper', function
141147
});
142148

143149
QUnit.test('bound `hash` params are provided with their original paths', function() {
144-
expect(1);
150+
expect(2);
145151

146152
function someHelper(options) {
147153
equal(options.hash.bestFriend, 'value');
@@ -160,7 +166,7 @@ QUnit.test('bound `hash` params are provided with their original paths', functio
160166
});
161167

162168
QUnit.test('bound ordered params are provided with their original paths', function() {
163-
expect(2);
169+
expect(3);
164170

165171
function someHelper(param1, param2, options) {
166172
equal(param1, 'first');
@@ -181,7 +187,7 @@ QUnit.test('bound ordered params are provided with their original paths', functi
181187
});
182188

183189
QUnit.test('registering a helper created from `Ember.Handlebars.makeViewHelper` does not double wrap the helper', function() {
184-
expect(2);
190+
expect(3);
185191

186192
var ViewHelperComponent = Component.extend({
187193
layout: compile('woot!')
@@ -204,7 +210,7 @@ QUnit.test('registering a helper created from `Ember.Handlebars.makeViewHelper`
204210
});
205211

206212
QUnit.test('makes helpful assertion when called with invalid arguments', function() {
207-
expect(2);
213+
expect(3);
208214

209215
var ViewHelperComponent = Component.extend({
210216
layout: compile('woot!')
@@ -228,7 +234,7 @@ QUnit.test('makes helpful assertion when called with invalid arguments', functio
228234
});
229235

230236
QUnit.test('does not add `options.fn` if no block was specified', function() {
231-
expect(1);
237+
expect(2);
232238

233239
function someHelper(options) {
234240
ok(!options.fn, '`options.fn` is not present when block is not specified');
@@ -247,7 +253,7 @@ QUnit.test('does not add `options.fn` if no block was specified', function() {
247253
});
248254

249255
QUnit.test('does not return helper result if block was specified', function() {
250-
expect(1);
256+
expect(2);
251257

252258
function someHelper(options) {
253259
return 'asdf';
@@ -268,7 +274,7 @@ QUnit.test('does not return helper result if block was specified', function() {
268274
});
269275

270276
QUnit.test('allows usage of the template fn', function() {
271-
expect(1);
277+
expect(2);
272278

273279
function someHelper(options) {
274280
options.fn();
@@ -289,7 +295,7 @@ QUnit.test('allows usage of the template fn', function() {
289295
});
290296

291297
QUnit.test('allows usage of the template inverse', function() {
292-
expect(1);
298+
expect(2);
293299

294300
function someHelper(options) {
295301
options.inverse();
@@ -310,7 +316,7 @@ QUnit.test('allows usage of the template inverse', function() {
310316
});
311317

312318
QUnit.test('ordered param types are added to options.types', function() {
313-
expect(3);
319+
expect(4);
314320

315321
function someHelper(param1, param2, param3, options) {
316322
equal(options.types[0], 'NUMBER');
@@ -332,7 +338,7 @@ QUnit.test('ordered param types are added to options.types', function() {
332338
});
333339

334340
QUnit.test('`hash` params are to options.hashTypes', function() {
335-
expect(3);
341+
expect(4);
336342

337343
function someHelper(options) {
338344
equal(options.hashTypes.string, 'STRING');

0 commit comments

Comments
 (0)