options.hashTypes在Handlebars助手中做了什么?

时间:2015-01-21 05:17:03

标签: javascript ember.js handlebars.js

在Ember的inputtextarea手柄助手中有一个函数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

谢谢!

0 个答案:

没有答案