Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 58f121a

Browse files
committed
feat($interpolate): expose start/end symbols in run phase
previously the startSymbol() and endSymbol() getters were exposed only via provider in the config phase
1 parent cf6023e commit 58f121a

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

src/ng/interpolate.js

+38-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function $InterpolateProvider() {
8989
* against.
9090
*
9191
*/
92-
return function(text, mustHaveExpression) {
92+
function $interpolate(text, mustHaveExpression) {
9393
var startIndex,
9494
endIndex,
9595
index = 0,
@@ -141,7 +141,43 @@ function $InterpolateProvider() {
141141
fn.parts = parts;
142142
return fn;
143143
}
144-
};
144+
}
145+
146+
147+
/**
148+
* @ngdoc method
149+
* @name ng.$interpolate#startSymbol
150+
* @methodOf ng.$interpolate
151+
* @description
152+
* Symbol to denote the start of expression in the interpolated string. Defaults to `{{`.
153+
*
154+
* Use {@link ng.$interpolateProvider#startSymbol $interpolateProvider#startSymbol} to change
155+
* the symbol.
156+
*
157+
* @returns {string} start symbol.
158+
*/
159+
$interpolate.startSymbol = function() {
160+
return startSymbol;
161+
}
162+
163+
164+
/**
165+
* @ngdoc method
166+
* @name ng.$interpolate#endSymbol
167+
* @methodOf ng.$interpolate
168+
* @description
169+
* Symbol to denote the end of expression in the interpolated string. Defaults to `}}`.
170+
*
171+
* Use {@link ng.$interpolateProvider#endSymbol $interpolateProvider#endSymbol} to change
172+
* the symbol.
173+
*
174+
* @returns {string} start symbol.
175+
*/
176+
$interpolate.endSymbol = function() {
177+
return endSymbol;
178+
}
179+
180+
return $interpolate;
145181
}];
146182
}
147183

test/ng/interpolateSpec.js

+10
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ describe('$interpolate', function() {
113113
}));
114114

115115

116+
it('should expose the startSymbol in run phase', inject(function($interpolate) {
117+
expect($interpolate.startSymbol()).toBe('((');
118+
}));
119+
120+
116121
it('should not get confused by matching start and end symbols', function() {
117122
module(function($interpolateProvider) {
118123
$interpolateProvider.startSymbol('--');
@@ -139,5 +144,10 @@ describe('$interpolate', function() {
139144
it('should expose the endSymbol in config phase', module(function($interpolateProvider) {
140145
expect($interpolateProvider.endSymbol()).toBe('))');
141146
}));
147+
148+
149+
it('should expose the endSymbol in run phase', inject(function($interpolate) {
150+
expect($interpolate.endSymbol()).toBe('))');
151+
}));
142152
});
143153
});

0 commit comments

Comments
 (0)