Skip to content
This repository has been archived by the owner on Jun 19, 2018. It is now read-only.

Commit

Permalink
fix(templates): replace the default interpolation symbol with the use…
Browse files Browse the repository at this point in the history
…r configured one

Closes #309
  • Loading branch information
Matt Lewis committed Mar 31, 2016
1 parent 7bf98bd commit 73a052e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ module.exports = angular
}
});
})
.run(function($templateCache) {
.run(function($templateCache, $interpolate) {

angular.forEach(templates, function(template) {
if (!$templateCache.get(template.cacheTemplateName)) {
$templateCache.put(template.cacheTemplateName, template.template);
var templateContents = template.template
.replace('{{', $interpolate.startSymbol())
.replace('}}', $interpolate.endSymbol());
$templateCache.put(template.cacheTemplateName, templateContents);
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/templates/calendarMonthCell.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<ng-include src="vm.calendarConfig.templates.calendarMonthCellEvents"></ng-include>

<div id="cal-week-box" ng-if="$first && rowHovered">
{{ vm.calendarConfig.i18nStrings.weekNumber.replace('{week}', day.date.clone().add(1, 'day').isoWeek()) }}
<span ng-bind="vm.calendarConfig.i18nStrings.weekNumber.replace('{week}', day.date.clone().add(1, 'day').isoWeek())"></span>
</div>

</div>
22 changes: 22 additions & 0 deletions test/unit/config.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

var angular = require('angular');

describe('calendar config', function() {

beforeEach(angular.mock.module('mwl.calendar', function($interpolateProvider) {
$interpolateProvider.startSymbol('[[');
$interpolateProvider.endSymbol(']]');
}));

var $templateCache;

beforeEach(inject(function(_$templateCache_) {
$templateCache = _$templateCache_;
}));

it('should replace the interpolation symbol with the user configured one in templates', function() {
expect($templateCache.get('mwl/calendarMonthCell.html').indexOf('class="cal-month-day [[ day.cssClass ]]"') > -1).to.be.true;
});

});

0 comments on commit 73a052e

Please sign in to comment.