feat(templating): progress on templating rethink

This commit is contained in:
Torkel Ödegaard
2016-02-29 17:31:31 +01:00
parent 078e69d06d
commit cb8b038795
5 changed files with 28 additions and 24 deletions

View File

@@ -31,13 +31,18 @@ function (angular, _) {
}, this);
};
this.regexEscape = function(value) {
return value.replace(/[-[\]{}()*+!<=:?.\/\\^$|#\s,]/g, '\\$&');
};
this.formatValue = function(value, format) {
if (_.isString(value)) {
return value;
} else {
switch(format) {
case "regex values": {
return '(' + value.join('|') + ')';
case "regex": {
var escapedValues = _.map(value, this.regexEscape);
return '(' + escapedValues.join('|') + ')';
}
case "lucene": {
var quotedValues = _.map(value, function(val) {