StackGenVis: Alignment of Data, Algorithms, and Models for Stacking Ensemble Learning Using Performance Metrics https://doi.org/10.1109/TVCG.2020.3030352
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
StackGenVis/frontend/node_modules/templates/lib/helpers/plural.js

56 lines
1.6 KiB

'use strict';
var debug = require('debug')('base:templates:helper');
var utils = require('../utils');
var List = require('../list');
module.exports = function(app, collection) {
var plural = collection.options.plural;
/**
* Creates an async helper for each view collection, and exposes
* the collection as an instance of `List` to the helper context.
*
* If the helper is used as a handlebars block helper, the collection
* array will be exposed as context to `options.fn()`, otherwise
* the `List` array is returned.
*
* ```js
* // create a collection
* app.create('pages');
*
* // use the `pages` helper
* // {{#pages}} ... {{/pages}}
* ```
* @param {Object} `options` Locals or handlebars options object
* @param {String} `callback` Handled internally by the templates library.
* @api public
*/
app.asyncHelper(plural, function listHelper(options, cb) {
if (typeof options === 'function') {
cb = options;
options = {};
}
options = options || {};
if (typeof options === 'string') {
var singular = this.app.getAsyncHelper(collection.options.inflection) ||
app.getAsyncHelper(collection.options.inflection);
return singular.apply(this, arguments);
}
debug('list helper "%s", "%j"', plural, options);
var ctx = new List(collection);
// render block helper with list as context
if (typeof options.fn === 'function' && options.hash) {
cb(null, options.fn(ctx));
return;
}
// return list when not used as a block helper
cb(null, ctx);
});
};