mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-17 03:01:06 +00:00
feat($interpolate): expose start/end symbols in run phase
previously the startSymbol() and endSymbol() getters were exposed only via provider in the config phase
This commit is contained in:
parent
cf6023ef22
commit
58f121a5c2
2 changed files with 48 additions and 2 deletions
|
|
@ -89,7 +89,7 @@ function $InterpolateProvider() {
|
||||||
* against.
|
* against.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
return function(text, mustHaveExpression) {
|
function $interpolate(text, mustHaveExpression) {
|
||||||
var startIndex,
|
var startIndex,
|
||||||
endIndex,
|
endIndex,
|
||||||
index = 0,
|
index = 0,
|
||||||
|
|
@ -141,7 +141,43 @@ function $InterpolateProvider() {
|
||||||
fn.parts = parts;
|
fn.parts = parts;
|
||||||
return fn;
|
return fn;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc method
|
||||||
|
* @name ng.$interpolate#startSymbol
|
||||||
|
* @methodOf ng.$interpolate
|
||||||
|
* @description
|
||||||
|
* Symbol to denote the start of expression in the interpolated string. Defaults to `{{`.
|
||||||
|
*
|
||||||
|
* Use {@link ng.$interpolateProvider#startSymbol $interpolateProvider#startSymbol} to change
|
||||||
|
* the symbol.
|
||||||
|
*
|
||||||
|
* @returns {string} start symbol.
|
||||||
|
*/
|
||||||
|
$interpolate.startSymbol = function() {
|
||||||
|
return startSymbol;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc method
|
||||||
|
* @name ng.$interpolate#endSymbol
|
||||||
|
* @methodOf ng.$interpolate
|
||||||
|
* @description
|
||||||
|
* Symbol to denote the end of expression in the interpolated string. Defaults to `}}`.
|
||||||
|
*
|
||||||
|
* Use {@link ng.$interpolateProvider#endSymbol $interpolateProvider#endSymbol} to change
|
||||||
|
* the symbol.
|
||||||
|
*
|
||||||
|
* @returns {string} start symbol.
|
||||||
|
*/
|
||||||
|
$interpolate.endSymbol = function() {
|
||||||
|
return endSymbol;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $interpolate;
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,11 @@ describe('$interpolate', function() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
it('should expose the startSymbol in run phase', inject(function($interpolate) {
|
||||||
|
expect($interpolate.startSymbol()).toBe('((');
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
it('should not get confused by matching start and end symbols', function() {
|
it('should not get confused by matching start and end symbols', function() {
|
||||||
module(function($interpolateProvider) {
|
module(function($interpolateProvider) {
|
||||||
$interpolateProvider.startSymbol('--');
|
$interpolateProvider.startSymbol('--');
|
||||||
|
|
@ -139,5 +144,10 @@ describe('$interpolate', function() {
|
||||||
it('should expose the endSymbol in config phase', module(function($interpolateProvider) {
|
it('should expose the endSymbol in config phase', module(function($interpolateProvider) {
|
||||||
expect($interpolateProvider.endSymbol()).toBe('))');
|
expect($interpolateProvider.endSymbol()).toBe('))');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
it('should expose the endSymbol in run phase', inject(function($interpolate) {
|
||||||
|
expect($interpolate.endSymbol()).toBe('))');
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue