File tree 4 files changed +13
-13
lines changed
4 files changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -27,10 +27,11 @@ class Interpolate implements Function {
27
27
28
28
String call (String template, [bool mustHaveExpression = false ,
29
29
String startSymbol = '{{' , String endSymbol = '}}' ]) {
30
+ if (template == null || template.isEmpty) return "" ;
30
31
31
- int startLen = startSymbol.length;
32
- int endLen = endSymbol.length;
33
- int length = template.length;
32
+ final startLen = startSymbol.length;
33
+ final endLen = endSymbol.length;
34
+ final length = template.length;
34
35
35
36
int startIdx;
36
37
int endIdx;
@@ -45,9 +46,7 @@ class Interpolate implements Function {
45
46
startIdx = template.indexOf (startSymbol, index);
46
47
endIdx = template.indexOf (endSymbol, startIdx + startLen);
47
48
if (startIdx != - 1 && endIdx != - 1 ) {
48
- if (index < startIdx) {
49
- expParts.add ('"${template .substring (index , startIdx )}"' );
50
- }
49
+ expParts.add ('"${template .substring (index , startIdx )}"' );
51
50
expParts.add ('(${template .substring (startIdx + startLen , endIdx )})' );
52
51
index = endIdx + endLen;
53
52
hasInterpolation = true ;
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ class NgTextMustacheDirective {
16
16
}
17
17
18
18
void _updateMarkup (text, previousText) {
19
- if (text != previousText) _element.text = text. toString () ;
19
+ if (text != previousText) _element.text = text;
20
20
}
21
21
}
22
22
@@ -48,7 +48,7 @@ class NgAttrMustacheDirective {
48
48
}
49
49
50
50
void _updateMarkup (text, previousText) {
51
- if (previousText != text) _attrs[_attrName] = text. toString () ;
51
+ if (previousText != text) _attrs[_attrName] = text;
52
52
}
53
53
}
54
54
Original file line number Diff line number Diff line change @@ -174,6 +174,6 @@ class NgPluralizeDirective {
174
174
}
175
175
176
176
void _updateMarkup (text, previousText) {
177
- if (text != previousText) element.text = text. toString () ;
177
+ if (text != previousText) element.text = text;
178
178
}
179
179
}
Original file line number Diff line number Diff line change @@ -18,10 +18,11 @@ main() {
18
18
expect ($interpolate ('Hello {{name}}!' )).toEqual ('"Hello "+(name)+"!"' );
19
19
expect ($interpolate ('a{{b}}C' )).toEqual ('"a"+(b)+"C"' );
20
20
expect ($interpolate ('a{{b}}' )).toEqual ('"a"+(b)' );
21
- expect ($interpolate ('{{a}}b' )).toEqual ('(a)+"b"' );
22
- expect ($interpolate ('{{b}}' )).toEqual ('(b)' );
23
- expect ($interpolate ('{{b}}+{{c}}' )).toEqual ('(b)+"+"+(c)' );
24
- expect ($interpolate ('{{b}}x{{c}}' )).toEqual ('(b)+"x"+(c)' );
21
+ expect ($interpolate ('{{a}}b' )).toEqual ('""+(a)+"b"' );
22
+ expect ($interpolate ('{{a}}{{b}}' )).toEqual ('""+(a)+""+(b)' );
23
+ expect ($interpolate ('{{b}}' )).toEqual ('""+(b)' );
24
+ expect ($interpolate ('{{b}}+{{c}}' )).toEqual ('""+(b)+"+"+(c)' );
25
+ expect ($interpolate ('{{b}}x{{c}}' )).toEqual ('""+(b)+"x"+(c)' );
25
26
});
26
27
27
28
it ('should Parse Multiline' , (Interpolate $interpolate) {
You can’t perform that action at this time.
0 commit comments