Sha256: ac641a5252427612e25067e4099bd00d041de98804175db43c570161a7f2293e

Contents?: true

Size: 882 Bytes

Versions: 5

Compression:

Stored size: 882 Bytes

Contents

slices.ENTRY_TEMPLATES = {
  name: function(key) {
    return '<td class="name"><a href="{{url}}">{{name}}</a></td>';
  },

  url: function(key) {
    return null;
  },

  _default: function(key) {
    return '<td class="{{' + key + '}}">{{' + key + '}}</td>';
  }
};


/*
 * Registers an entry template function for the given key.
 * The function takes `key` and should return a string.
 * Template compilation happens elsewhere.
 *
 * @param {String} key
 * @param {Function} fun
 */

slices.registerEntryTemplate = function(key, fun) {
  slices.ENTRY_TEMPLATES[key] = fun;
}

/*
 * Returns the entry template for the given key.
 *
 * If not special templates are registered, the default
 * template is returned.
 *
 * @return {String}
 */

slices.entryTemplate = function(key) {
  var fun = slices.ENTRY_TEMPLATES[key] || slices.ENTRY_TEMPLATES['_default'];
  return fun(key);
}

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
slices-2.0.2 app/assets/javascripts/slices/app/helpers/entries.js
slices-2.0.1 app/assets/javascripts/slices/app/helpers/entries.js
slices-2.0.0 app/assets/javascripts/slices/app/helpers/entries.js
slices-1.0.5 app/assets/javascripts/slices/app/helpers/entries.js
slices-1.0.4 app/assets/javascripts/slices/app/helpers/entries.js