less-plugin-sass2less
Version:
A plugin for less that converts SASS files into LESS. It comes with a cmd utility too.
13 lines (12 loc) • 495 B
JavaScript
module.exports = {
pattern: /@for\s([\w$]+)\sfrom\s([\w$]+)\s(through|to)\s(.*)\s\{((?:[^}{]+|\{(?:[^}{]+|\{[^}{]*\})*\})*)\}/gi,
replacement: function(match, iterator, initial, through, to, body) {
let operator = through === 'through' ? '<=' : '<'
return `.for(${iterator}: ${initial}) when (${iterator} ${operator} ${to}) {` +
`${body.replace(new RegExp('(?:\#{)?' + iterator + '}?', 'gi'), '@{' + iterator + '}')}` +
` .for((${iterator} + 1));
}
.for();`
},
order: 0
}