Browse files

sort-group: remove parens when zipping

  • Loading branch information...
1 parent 7daf894 commit 711c13c9603215c0e2d2c426524e60eba6130d41 @indutny indutny committed Jan 25, 2013
Showing with 14 additions and 2 deletions.
  1. +14 −2 lib/xjst/engines/sort-group.js
View
16 lib/xjst/engines/sort-group.js
@@ -276,8 +276,20 @@ exports.execute = function engine(templates, options, config) {
function zip(templates) {
return templates.map(function(template) {
var matches = template[0].slice().map(function(match) {
- var pred = match[1];
- while (pred[0] === 'unop' && pred[1] === '!') pred = pred[2];
+ var pred = match[1],
+ changed;
+
+ do {
+ changed = false;
+ if (pred[0] === 'unop' && pred[1] === '!') {
+ changed = true;
+ pred = pred[2];
+ }
+ if (pred[0] === 'parens') {
+ changed = true;
+ pred = pred[1];
+ }
+ } while (changed);
return [utils.stringify(pred), match];
});

0 comments on commit 711c13c

Please sign in to comment.