mozilla / nunjucks
Showing 3 of 5 files from the diff.

@@ -82,7 +82,7 @@
Loading
82 82
}
83 83
84 84
function makeMacro(argNames, kwargNames, func) {
85 -
  return (...macroArgs) => {
85 +
  return function macro(...macroArgs) {
86 86
    var argCount = numArgs(macroArgs);
87 87
    var args;
88 88
    var kwargs = getKeywordArgs(macroArgs);

@@ -447,13 +447,21 @@
Loading
447 447
448 448
exports.sort = r.makeMacro(
449 449
  ['value', 'reverse', 'case_sensitive', 'attribute'], [],
450 -
  (arr, reversed, caseSens, attr) => {
450 +
  function sortFilter(arr, reversed, caseSens, attr) {
451 451
    // Copy it
452 452
    let array = lib.map(arr, v => v);
453 +
    let getAttribute = lib.getAttrGetter(attr);
453 454
454 455
    array.sort((a, b) => {
455 -
      let x = (attr) ? a[attr] : a;
456 -
      let y = (attr) ? b[attr] : b;
456 +
      let x = (attr) ? getAttribute(a) : a;
457 +
      let y = (attr) ? getAttribute(b) : b;
458 +
459 +
      if (
460 +
        this.env.opts.throwOnUndefined &&
461 +
        attr && (x === undefined || y === undefined)
462 +
      ) {
463 +
        throw new TypeError(`sort: attribute "${attr}" resolved to undefined`);
464 +
      }
457 465
458 466
      if (!caseSens && lib.isString(x) && lib.isString(y)) {
459 467
        x = x.toLowerCase();

@@ -210,6 +210,8 @@
Loading
210 210
  };
211 211
}
212 212
213 +
exports.getAttrGetter = getAttrGetter;
214 +
213 215
function groupBy(obj, val, throwOnUndefined) {
214 216
  const result = {};
215 217
  const iterator = isFunction(val) ? val : getAttrGetter(val);
Files Coverage
nunjucks 89.69%
Project Totals (22 files) 89.69%
j18l4e3j36rys6v1
l36ww42smo3cmn04
q9un2aemt3s9kt1c
026hwlv7wumapcsk
ltdaiawq9m6e39qh
hx0i75eiplpqcabg
u4nn877omphpvq69
hebh7tkcikkf6slp
c0mo3l5x6jeggf58
wagkeyv0kqwtn0nh
nv9e58x35c8kh1un
plh6em1orm4ldro0
1
comment:
2
  require_changes: yes
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading