Skip to content

Commit 6571ac5

Browse files
committedMay 25, 2015
lift filter arg processing function
1 parent 5dfa2f0 commit 6571ac5

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed
 

‎src/parsers/directive.js

+18-9
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,7 @@ function pushFilter () {
5151
var tokens = exp.match(filterTokenRE)
5252
filter.name = tokens[0]
5353
if (tokens.length > 1) {
54-
filter.args = tokens.slice(1).map(function (arg) {
55-
var stripped = reservedArgRE.test(arg)
56-
? arg
57-
: _.stripQuotes(arg)
58-
return {
59-
value: stripped || arg,
60-
dynamic: !stripped
61-
}
62-
})
54+
filter.args = tokens.slice(1).map(processFilterArg)
6355
}
6456
}
6557
if (filter) {
@@ -68,6 +60,23 @@ function pushFilter () {
6860
lastFilterIndex = i + 1
6961
}
7062

63+
/**
64+
* Check if an argument is dynamic and strip quotes.
65+
*
66+
* @param {String} arg
67+
* @return {Object}
68+
*/
69+
70+
function processFilterArg (arg) {
71+
var stripped = reservedArgRE.test(arg)
72+
? arg
73+
: _.stripQuotes(arg)
74+
return {
75+
value: stripped || arg,
76+
dynamic: !stripped
77+
}
78+
}
79+
7180
/**
7281
* Parse a directive string into an Array of AST-like
7382
* objects representing directives.

0 commit comments

Comments
 (0)
Please sign in to comment.