{"action":"closed","issue":{"url":"https://api.github.com/repos/phalcon/cphalcon/issues/2349","repository_url":"https://api.github.com/repos/phalcon/cphalcon","labels_url":"https://api.github.com/repos/phalcon/cphalcon/issues/2349/labels{/name}","comments_url":"https://api.github.com/repos/phalcon/cphalcon/issues/2349/comments","events_url":"https://api.github.com/repos/phalcon/cphalcon/issues/2349/events","html_url":"https://github.com/phalcon/cphalcon/issues/2349","id":31576099,"number":2349,"title":"[NFR] Volt output filters","user":{"login":"scento","id":2129596,"avatar_url":"https://avatars2.githubusercontent.com/u/2129596?v=4","gravatar_id":"","url":"https://api.github.com/users/scento","html_url":"https://github.com/scento","followers_url":"https://api.github.com/users/scento/followers","following_url":"https://api.github.com/users/scento/following{/other_user}","gists_url":"https://api.github.com/users/scento/gists{/gist_id}","starred_url":"https://api.github.com/users/scento/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scento/subscriptions","organizations_url":"https://api.github.com/users/scento/orgs","repos_url":"https://api.github.com/users/scento/repos","events_url":"https://api.github.com/users/scento/events{/privacy}","received_events_url":"https://api.github.com/users/scento/received_events","type":"User","site_admin":false},"labels":[{"id":13573146,"url":"https://api.github.com/repos/phalcon/cphalcon/labels/New%20Feature%20Request","name":"New Feature Request","color":"0052cc","default":false},{"id":724046205,"url":"https://api.github.com/repos/phalcon/cphalcon/labels/Volt","name":"Volt","color":"000000","default":false},{"id":903580634,"url":"https://api.github.com/repos/phalcon/cphalcon/labels/stale","name":"stale","color":"ffffff","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/phalcon/cphalcon/milestones/21","html_url":"https://github.com/phalcon/cphalcon/milestone/21","labels_url":"https://api.github.com/repos/phalcon/cphalcon/milestones/21/labels","id":1912191,"number":21,"title":"4.0.0","description":"","creator":{"login":"sergeyklay","id":1256298,"avatar_url":"https://avatars2.githubusercontent.com/u/1256298?v=4","gravatar_id":"","url":"https://api.github.com/users/sergeyklay","html_url":"https://github.com/sergeyklay","followers_url":"https://api.github.com/users/sergeyklay/followers","following_url":"https://api.github.com/users/sergeyklay/following{/other_user}","gists_url":"https://api.github.com/users/sergeyklay/gists{/gist_id}","starred_url":"https://api.github.com/users/sergeyklay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergeyklay/subscriptions","organizations_url":"https://api.github.com/users/sergeyklay/orgs","repos_url":"https://api.github.com/users/sergeyklay/repos","events_url":"https://api.github.com/users/sergeyklay/events{/privacy}","received_events_url":"https://api.github.com/users/sergeyklay/received_events","type":"User","site_admin":false},"open_issues":37,"closed_issues":59,"state":"open","created_at":"2016-07-29T16:36:07Z","updated_at":"2018-04-16T20:30:23Z","due_on":null,"closed_at":null},"comments":10,"created_at":"2014-04-15T18:01:48Z","updated_at":"2018-04-16T20:30:23Z","closed_at":"2018-04-16T20:30:23Z","author_association":"CONTRIBUTOR","body":"**Description**\nSince Volt is by default caching generated php templates, it might be useful to apply even time-consumpting filters on the output created at this stage. Filters could for example minify the HTML source code or do any further optimization.\n\n**Usage Example**\n\n```\nuse \\Phalcon\\View\\Engine\\Volt\\Filters\\HTMLMinify,\n    \\Phalcon\\Mvc\\View\\Engine\\Volt;\n\n[...]\n\n$di->set('view', function() {\n        $view = new View();\n        $view->setViewsDir('../app/views/');\n        $view->registerEngines(array(\n            '.volt' => function($view, $di) {\n                $volt = new Volt($view, $di);\n                $volt->addFilter(new HTMLMinify());\n\n                return $volt;\n            }\n            ));\n        return $view;\n    });\n```\n\n**Framework Integration**\nThe filter integration would match the filter integration of the `Phalcon\\Assets\\Manager` class. All filters should implement `FilterInterface`.\n\n**Suggested Additional Classes, Interfaces, Methods and Member Variables**\n-   _`\\Phalcon\\Mvc\\View\\Engine\\Volt`_\n  \n  ```\n  class Volt extends Engine implements InjectionAwareInterface, \n  EventsAwareInterface, EngineInterface\n  {\n      /**\n       * Filters\n       *\n       * @var array|null\n       * @access protected\n      */\n      protected $_filters = null;\n  \n      /**\n       * Apply filter on output\n       *\n       * @param FilterInterface $filter\n      */\n      public function addFilter(FilterInterface $filter) {}\n  \n      /**\n       * Remove applied filter\n       *\n       * @param FilterInterface $filter\n      */\n      public function removeFilter(FilterInterface $filter) {}\n  \n      /**\n       * Get applied filters\n       *\n       * @return array\n      */\n      public function getFilters() {}\n  }\n  ```\n-   _`\\Phalcon\\Mvc\\View\\Engine\\Volt\\FilterInterface`_\n  \n  ```\n  interface FilterInterface\n  {\n      /**\n       * Filters $content and returns the output\n       *\n       * @param string $content\n       * @return string\n       * @throws \\Phalcon\\Mvc\\View\\Exception\n      */\n      public function filter($content);\n  }\n  ```\n-   _`\\Phalcon\\Mvc\\View\\Engine\\Volt\\Filters\\HTMLMinify`_\n  \n  ```\n  class HTMLMinify implements FilterInterface\n  {\n      /**\n       * Applies php_strip_whitespace and minifies the HTML code around\n       *\n       * @param string $content\n       * @return string\n       * @throws \\Phalcon\\Mvc\\View\\Exception\n      */\n      public function filter($content);\n  }\n  ```\n## <bountysource-plugin>\n\nWant to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/1678464-nfr-volt-output-filters?utm_campaign=plugin&utm_content=tracker%2F50707&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F50707&utm_medium=issues&utm_source=github).\n</bountysource-plugin>\n"}}
{"actor":{"display_login":"sergeyklay"}}