Sha256: cbf08912cb7aabe4aad56781753cea82a978995234b266db2cf429c77b107ef0
Contents?: true
Size: 1.39 KB
Versions: 1
Compression:
Stored size: 1.39 KB
Contents
sc_require('ext/handlebars'); Handlebars.registerHelper('collection', function(path, options) { var fn = options.fn; var data = options.data; var inverse = options.inverse; var collectionClass, collectionObject; collectionClass = path ? SC.objectForPropertyPath(path) : SC.TemplateCollectionView; //@ if (debug) if (!collectionClass) { throw "%@ #collection: Could not find %@".fmt(data.view, path); } //@ endif var hash = fn.hash, itemHash = {}, match; for (var prop in hash) { if (fn.hash.hasOwnProperty(prop)) { match = prop.match(/^item(.)(.*)$/); if(match) { itemHash[match[1].toLowerCase() + match[2]] = hash[prop]; delete hash[prop]; } } } if(fn) { var extensions = { itemViewTemplate: fn, inverseTemplate: inverse, itemViewOptions: itemHash }; if(collectionClass.isClass) { collectionObject = collectionClass.extend(extensions); } else { SC.mixin(collectionClass, extensions); collectionObject = collectionClass; } } options.fn = function() { return ""; }; return Handlebars.helpers.view.call(this, collectionObject, options); }); Handlebars.registerHelper('each', function(path, options) { options.hash.contentBinding = SC.Binding.from('*'+path, this); options.hash.itemContextProperty = 'content'; return Handlebars.helpers.collection.call(this, null, options); });
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sproutcore-1.5.0.rc.2 | lib/frameworks/sproutcore/frameworks/core_foundation/ext/handlebars/collection.js |