Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

splitcharacters filter Updates #20

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var myApp = angular.module('myApp', ['truncate']);
###When outputting text, apply the filter.
```html
<p>
{{ text | characters:25 }} or {{ text | words:5 }}
{{ text | characters:25 }} or {{ text | splitcharacters:5 }} or {{ text | words:5 }}
</p>
```

Expand All @@ -32,4 +32,4 @@ By default, a _word_ will not be truncated. Set the optional boolean after the c
<p>
{{ text | characters:25 :true}}
</p>
```
```
2 changes: 1 addition & 1 deletion src/truncate.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ angular.module('truncate', [])
if (input && input.length > chars) {
var prefix = input.substring(0, chars/2);
var postfix = input.substring(input.length-chars/2, input.length);
return prefix + '...' + postfix;
return prefix + '' + postfix;
}
return input;
};
Expand Down
4 changes: 2 additions & 2 deletions test/unit/filtersSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ describe('truncate', function () {
});

it('should trim these down', function () {
expect(characterFilter('1234567890', 5)).toEqual('12...890');
expect(characterFilter('1234567890', 5)).toEqual('12890');
});

it('should trim this down including the space', function () {
expect(characterFilter('123456789 10 11 12 13 14', 13)).toEqual('123456...2 13 14');
expect(characterFilter('123456789 10 11 12 13 14', 13)).toEqual('1234562 13 14');
});

it('should handle invalid numbers', function () {
Expand Down