Closed sensone closed 7 years ago
Some comments:
|
is also a valid JavaScript operator, so collection | something
might still be meaningful (though no so meaningful since it's a bitwise operator)|
be chained in your implementation? e.g. el in collection | sort | first
collection
argument, so that it's transformed into the equivalent "map" expression. E.g. instead of...
data.collection = arr[1].trim();
...
something like this:
...
data.collection = filterOperator(arr[1].trim());
...
function filterOperator(collection) {
if(collection.indexOf("|")<0) return collection;
// parse "|" here
return `_.map(${collection}, ... , .... )`;
}
|
syntax could be extended to all other template expressions, eg { someText | upperCase }
but I don't know if maintainers will accept this syntax extension.As regards unit testing, write a test/repeat-filter.rt
file and its compiled version test/repeat-filter.js
. Then modify test/src/rt.valid.spec.js
simply adding your file name in the function that tests repeat.rt
.
Run tests with npm run test
or npm run all
.
Hi everyone, I think the filter in rt-repeat is a very good functionality. I propose to use the same syntax as in AngularJS with less count of options.
For example:
It will be transformed to:
But I need help with unit tests. Could you help me? And please review my code.