Permalink
Browse files

feat($interpolate): expose start/end symbols in run phase

previously the startSymbol() and endSymbol() getters were exposed only via provider
in the config phase
  • Loading branch information...
IgorMinar committed Aug 11, 2012
1 parent cf6023e commit 58f121a5c293ed57043e22ed526fdf99642fca81
Showing with 48 additions and 2 deletions.
  1. +38 −2 src/ng/interpolate.js
  2. +10 −0 test/ng/interpolateSpec.js
View
@@ -89,7 +89,7 @@ function $InterpolateProvider() {
* against.
*
*/
return function(text, mustHaveExpression) {
function $interpolate(text, mustHaveExpression) {
var startIndex,
endIndex,
index = 0,
@@ -141,7 +141,43 @@ function $InterpolateProvider() {
fn.parts = parts;
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;
}];
}
View
@@ -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() {
module(function($interpolateProvider) {
$interpolateProvider.startSymbol('--');
@@ -139,5 +144,10 @@ describe('$interpolate', function() {
it('should expose the endSymbol in config phase', module(function($interpolateProvider) {
expect($interpolateProvider.endSymbol()).toBe('))');
}));
it('should expose the endSymbol in run phase', inject(function($interpolate) {
expect($interpolate.endSymbol()).toBe('))');
}));
});
});

0 comments on commit 58f121a

Please sign in to comment.