Skip to content

Commit

Permalink
Merge pull request #647 from hannu/clean-default-var
Browse files Browse the repository at this point in the history
Clean up default suffix on variable values
  • Loading branch information
hannu committed Jun 9, 2015
2 parents d910df7 + 3cbfe23 commit 4588b0b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/app/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ angular.module('sgApp', [
}

angular.forEach(sortedVariables, function(variable) {
str = str.replace(new RegExp('\[\$\@]' + variable.name, 'g'), variable.value);
var cleanedValue = variable.value.replace(/\s*\!default$/, '');
str = str.replace(new RegExp('\[\$\@]' + variable.name, 'g'), cleanedValue);
});
return str;
};
Expand Down
18 changes: 18 additions & 0 deletions test/angular/unit/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ describe('sgApp module', function() {
result = 'background: $test;';
expect(setVariables(input, variables)).to.eql(result);
});

it('should clean up !default suffix', function() {
var input = 'background: $bgColor;',
variables = [
{name: 'bgColor', value: '#FF0000 !default'}
],
result = 'background: #FF0000;';
expect(setVariables(input, variables)).to.eql(result);
});
});

describe('LESS "@" variables', function() {
Expand Down Expand Up @@ -127,6 +136,15 @@ describe('sgApp module', function() {
result = 'background: @test;';
expect(setVariables(input, variables)).to.eql(result);
});

it('should clean up !default suffix', function() {
var input = 'background: @bgColor;',
variables = [
{name: 'bgColor', value: '#FF0000 !default'}
],
result = 'background: #FF0000;';
expect(setVariables(input, variables)).to.eql(result);
});
});
});

Expand Down

0 comments on commit 4588b0b

Please sign in to comment.