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.
57 lines
1.3 KiB
57 lines
1.3 KiB
'use strict';
|
|
|
|
var debug = require('debug')('base:templates:helper');
|
|
var utils = require('../utils');
|
|
|
|
module.exports = function(app) {
|
|
|
|
/**
|
|
* Get a specific view by `name`, optionally specifying
|
|
* the view's collection as the second argument, to limit
|
|
* (and potentially speed up) the lookup.
|
|
*
|
|
* ```html
|
|
* <%%= view("foo") %>
|
|
* ```
|
|
* @param {String} `name`
|
|
* @param {String} `collection`
|
|
* @return {String}
|
|
* @api public
|
|
*/
|
|
|
|
app.asyncHelper('view', function(name, collectionName, locals, cb) {
|
|
debug('view helper, getting "%s"', name);
|
|
var args = [].slice.call(arguments, 1);
|
|
|
|
var last = utils.last(args);
|
|
if (typeof last === 'function') {
|
|
cb = args.pop();
|
|
}
|
|
|
|
last = utils.last(args);
|
|
if (utils.isObject(last)) {
|
|
locals = args.pop();
|
|
} else {
|
|
collectionName = args.pop();
|
|
}
|
|
|
|
var view = this.app.find(name, collectionName) || app.find(name, collectionName);
|
|
|
|
// if no view is found, return an empty string
|
|
if (!view) {
|
|
cb(null, '');
|
|
return;
|
|
}
|
|
|
|
// create the context
|
|
var ctx = this.context.merge(locals);
|
|
|
|
// render the view
|
|
view.render(ctx, function(err, res) {
|
|
if (err) return cb(err);
|
|
|
|
debug('"view" rendered helper "%s"', res.relative);
|
|
cb(null, res.content);
|
|
});
|
|
});
|
|
};
|
|
|