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

Commit

Permalink
feat($interpolate): expose start/end symbols in run phase
Browse files Browse the repository at this point in the history
previously the startSymbol() and endSymbol() getters were exposed only via provider
in the config phase
  • Loading branch information
IgorMinar committed Aug 13, 2012
1 parent cf6023e commit 58f121a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
40 changes: 38 additions & 2 deletions src/ng/interpolate.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function $InterpolateProvider() {
* against.
*
*/
return function(text, mustHaveExpression) {
function $interpolate(text, mustHaveExpression) {
var startIndex,
endIndex,
index = 0,
Expand Down Expand Up @@ -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;
}];
}

10 changes: 10 additions & 0 deletions test/ng/interpolateSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('--');
Expand All @@ -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.