@@ -41,6 +41,8 @@ var $interpolateMinErr = minErr('$interpolate');
41
41
function $InterpolateProvider ( ) {
42
42
var startSymbol = '{{' ;
43
43
var endSymbol = '}}' ;
44
+ var escapedStartSymbol = '\\{\\{' ;
45
+ var escapedEndSymbol = '\\}\\}' ;
44
46
45
47
/**
46
48
* @ngdoc method
@@ -134,17 +136,26 @@ function $InterpolateProvider() {
134
136
exp ,
135
137
concat = [ ] ;
136
138
139
+ function quoteForRegexp ( pattern ) {
140
+ return pattern . replace ( / [ \- \[ \] { } ( ) * + ? . , \\ \^ $ | # \s ] / g, "\\$&" )
141
+ }
142
+ function unescapeSymbols ( text ) {
143
+ var startSymbolRegexp = new RegExp ( quoteForRegexp ( escapedStartSymbol ) , 'g' ) ;
144
+ var endSymbolRegexp = new RegExp ( quoteForRegexp ( escapedEndSymbol ) , 'g' ) ;
145
+ return text . replace ( startSymbolRegexp , startSymbol ) . replace ( endSymbolRegexp , endSymbol ) ;
146
+ }
147
+
137
148
while ( index < length ) {
138
149
if ( ( ( startIndex = text . indexOf ( startSymbol , index ) ) != - 1 ) &&
139
150
( ( endIndex = text . indexOf ( endSymbol , startIndex + startSymbolLength ) ) != - 1 ) ) {
140
- ( index != startIndex ) && parts . push ( text . substring ( index , startIndex ) ) ;
151
+ ( index != startIndex ) && parts . push ( unescapeSymbols ( text . substring ( index , startIndex ) ) ) ;
141
152
parts . push ( fn = $parse ( exp = text . substring ( startIndex + startSymbolLength , endIndex ) ) ) ;
142
153
fn . exp = exp ;
143
154
index = endIndex + endSymbolLength ;
144
155
hasInterpolation = true ;
145
156
} else {
146
157
// we did not find anything, so we have to add the remainder to the parts array
147
- ( index != length ) && parts . push ( text . substring ( index ) ) ;
158
+ ( index != length ) && parts . push ( unescapeSymbols ( text . substring ( index ) ) ) ;
148
159
index = length ;
149
160
}
150
161
}
0 commit comments