在Ember的input
和textarea
手柄助手中有一个函数normalizeHash
:
function normalizeHash(hash, hashTypes) {
for (var prop in hash) {
if (hashTypes[prop] === 'ID') {
hash[prop + 'Binding'] = hash[prop];
delete hash[prop];
}
}
}
从hashTypes
传递options.hashTypes
:
Ember.Handlebars.registerHelper('input', function(options) {
Ember.assert('You can only pass attributes to the `input` helper, not arguments', arguments.length < 2);
var hash = options.hash,
types = options.hashTypes,
inputType = hash.type,
onEvent = hash.on;
delete hash.type;
delete hash.on;
normalizeHash(hash, types);
if (inputType === 'checkbox') {
return Ember.Handlebars.helpers.view.call(this, Ember.Checkbox, options);
} else {
hash.type = inputType;
hash.onEvent = onEvent || 'enter';
return Ember.Handlebars.helpers.view.call(this, Ember.TextField, options);
}
});
我一直在努力了解normalizeHash
正在做什么,但我找不到options.hashTypes
的任何文档。所以,我的问题是什么是options.hashTypes
?
谢谢!