{"action":"created","issue":{"url":"https://api.github.com/repos/timber/timber/issues/1193","repository_url":"https://api.github.com/repos/timber/timber","labels_url":"https://api.github.com/repos/timber/timber/issues/1193/labels{/name}","comments_url":"https://api.github.com/repos/timber/timber/issues/1193/comments","events_url":"https://api.github.com/repos/timber/timber/issues/1193/events","html_url":"https://github.com/timber/timber/pull/1193","id":177112828,"number":1193,"title":"Add excerpt chars filter","user":{"login":"CROSP","id":5072318,"avatar_url":"https://avatars.githubusercontent.com/u/5072318?v=3","gravatar_id":"","url":"https://api.github.com/users/CROSP","html_url":"https://github.com/CROSP","followers_url":"https://api.github.com/users/CROSP/followers","following_url":"https://api.github.com/users/CROSP/following{/other_user}","gists_url":"https://api.github.com/users/CROSP/gists{/gist_id}","starred_url":"https://api.github.com/users/CROSP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CROSP/subscriptions","organizations_url":"https://api.github.com/users/CROSP/orgs","repos_url":"https://api.github.com/users/CROSP/repos","events_url":"https://api.github.com/users/CROSP/events{/privacy}","received_events_url":"https://api.github.com/users/CROSP/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"jarednova","id":1298086,"avatar_url":"https://avatars.githubusercontent.com/u/1298086?v=3","gravatar_id":"","url":"https://api.github.com/users/jarednova","html_url":"https://github.com/jarednova","followers_url":"https://api.github.com/users/jarednova/followers","following_url":"https://api.github.com/users/jarednova/following{/other_user}","gists_url":"https://api.github.com/users/jarednova/gists{/gist_id}","starred_url":"https://api.github.com/users/jarednova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jarednova/subscriptions","organizations_url":"https://api.github.com/users/jarednova/orgs","repos_url":"https://api.github.com/users/jarednova/repos","events_url":"https://api.github.com/users/jarednova/events{/privacy}","received_events_url":"https://api.github.com/users/jarednova/received_events","type":"User","site_admin":false},"assignees":[{"login":"jarednova","id":1298086,"avatar_url":"https://avatars.githubusercontent.com/u/1298086?v=3","gravatar_id":"","url":"https://api.github.com/users/jarednova","html_url":"https://github.com/jarednova","followers_url":"https://api.github.com/users/jarednova/followers","following_url":"https://api.github.com/users/jarednova/following{/other_user}","gists_url":"https://api.github.com/users/jarednova/gists{/gist_id}","starred_url":"https://api.github.com/users/jarednova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jarednova/subscriptions","organizations_url":"https://api.github.com/users/jarednova/orgs","repos_url":"https://api.github.com/users/jarednova/repos","events_url":"https://api.github.com/users/jarednova/events{/privacy}","received_events_url":"https://api.github.com/users/jarednova/received_events","type":"User","site_admin":false}],"milestone":null,"comments":3,"created_at":"2016-09-15T07:56:40Z","updated_at":"2016-09-17T17:39:03Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/timber/timber/pulls/1193","html_url":"https://github.com/timber/timber/pull/1193","diff_url":"https://github.com/timber/timber/pull/1193.diff","patch_url":"https://github.com/timber/timber/pull/1193.patch"},"body":"#### Issue\r\n<!-- Description of the problem that this code change is solving -->\r\n\r\nAdd separate `Filter` class for commonly used filters. In this case add useful filter for trimming text\r\nstring to a certain amount of characters.\r\nDecouple `Twig` class. Move all filter methods like `add_list_separators` , `time_ago`. (Not included in this pull request).\r\n\r\n#### Solution\r\n<!-- Description of the solution that this code changes are introducing to the application. -->\r\n\r\nCreate new class `Filter`. Add `trim_characters` method. Modify `Twig` class, add new `Twig_SimpleFilter`\r\n\r\n#### Impact\r\n<!-- What impact will this have on the current codebase, performance, backwards compatability? -->\r\n\r\nUses `mb_strimwidth` (PHP 4 >= 4.0.6, PHP 5, PHP 7) , wordpress functions `__()` for localization and\r\n`wp_strip_all_tags` for striping all tags from input text.\r\n\r\n#### Usage\r\n<!-- Are there are any usage changes, or are there new usage that we need to know about? -->\r\n\r\nBy default string is trimmed to 60 characters. \r\n\r\n```\r\n   <p class=\"post-content__text\">\r\n                    {{ post.post_content|excerpt_chars }}\r\n    </p>\r\n```\r\nYou can specify desired characters amount \r\n\r\n```\r\n   <p class=\"post-content__text\">\r\n                    {{ post.post_content|excerpt_chars(130) }}\r\n    </p>\r\n```\r\n\r\nIt is possible to specify custom excerpt (more text). By default `&hellip;` is used\r\n\r\n```\r\n   <p class=\"post-content__text\">\r\n                    {{ post.post_content|excerpt_chars(130,'[...]') }}\r\n    </p>\r\n```\r\n#### Considerations\r\n<!-- As we do not live in an ideal world it's worth to share your thought on how we could make the solution even better. -->\r\n\r\nI would suggest to decouple `Twig` class and move all filters to the `Filter` class.\r\n"},"comment":{"url":"https://api.github.com/repos/timber/timber/issues/comments/247792446","html_url":"https://github.com/timber/timber/pull/1193#issuecomment-247792446","issue_url":"https://api.github.com/repos/timber/timber/issues/1193","id":247792446,"user":{"login":"jarednova","id":1298086,"avatar_url":"https://avatars.githubusercontent.com/u/1298086?v=3","gravatar_id":"","url":"https://api.github.com/users/jarednova","html_url":"https://github.com/jarednova","followers_url":"https://api.github.com/users/jarednova/followers","following_url":"https://api.github.com/users/jarednova/following{/other_user}","gists_url":"https://api.github.com/users/jarednova/gists{/gist_id}","starred_url":"https://api.github.com/users/jarednova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jarednova/subscriptions","organizations_url":"https://api.github.com/users/jarednova/orgs","repos_url":"https://api.github.com/users/jarednova/repos","events_url":"https://api.github.com/users/jarednova/events{/privacy}","received_events_url":"https://api.github.com/users/jarednova/received_events","type":"User","site_admin":false},"created_at":"2016-09-17T17:39:03Z","updated_at":"2016-09-17T17:39:03Z","body":"Thanks @CROSP! I agree, it might be time to simplify the organization of the Filter code. I'll take a look at this guy in the next few days"}}
{"actor":{"display_login":"jarednova"}}