In the input and textarea handlebar helpers in Ember there is a function normalizeHash:
function normalizeHash(hash, hashTypes) {
for (var prop in hash) {
if (hashTypes[prop] === 'ID') {
hash[prop + 'Binding'] = hash[prop];
delete hash[prop];
}
}
}
the hashTypes are passed in from 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);
}
});
I've been trying to understand what normalizeHash is doing but I can't find any documentation on options.hashTypes. So, my question is what is options.hashTypes?
Thanks!
Aucun commentaire:
Enregistrer un commentaire