{"action":"opened","issue":{"url":"https://api.github.com/repos/pojome/elementor/issues/966","repository_url":"https://api.github.com/repos/pojome/elementor","labels_url":"https://api.github.com/repos/pojome/elementor/issues/966/labels{/name}","comments_url":"https://api.github.com/repos/pojome/elementor/issues/966/comments","events_url":"https://api.github.com/repos/pojome/elementor/issues/966/events","html_url":"https://github.com/pojome/elementor/issues/966","id":192799333,"number":966,"title":"Idea: use a template system and filter content","user":{"login":"iamntz","id":132062,"avatar_url":"https://avatars.githubusercontent.com/u/132062?v=3","gravatar_id":"","url":"https://api.github.com/users/iamntz","html_url":"https://github.com/iamntz","followers_url":"https://api.github.com/users/iamntz/followers","following_url":"https://api.github.com/users/iamntz/following{/other_user}","gists_url":"https://api.github.com/users/iamntz/gists{/gist_id}","starred_url":"https://api.github.com/users/iamntz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iamntz/subscriptions","organizations_url":"https://api.github.com/users/iamntz/orgs","repos_url":"https://api.github.com/users/iamntz/repos","events_url":"https://api.github.com/users/iamntz/events{/privacy}","received_events_url":"https://api.github.com/users/iamntz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-12-01T09:54:24Z","updated_at":"2016-12-01T09:54:24Z","closed_at":null,"body":"Alright, so, I'm using [Handlebars](https://github.com/XaminProject/handlebars.php)¹ for couple of years on WP projects and I didn't had any issues.  I created a [wrapper](https://gist.github.com/iamntz/81293f1dae47311a8f84f375c400912e) that will allow you to use templates even in a parent/child theme setup.\r\n\r\nHere is an idea:\r\n\r\nMake all `render` methods to render Handlebars templates instead of mixed php/html. This will have multiple benefits:\r\n\r\n### Will completely separate PHP and HTML ([SRP](https://en.wikipedia.org/wiki/Single_responsibility_principle))\r\n\r\nThis is no brainer; having php and html mixed violates SRP, because you'll have two reasons to change a class.\r\n\r\n--- \r\nI prepared a sample on how you can convert an existing module: icon list.\r\n\r\nthe *whole* render method:\r\n```php\r\nprotected function render() {\r\n  $settings = $this->get_settings();\r\n  $render = [\r\n    'settings' => $settings,\r\n    'items' => $settings['icon_list']\r\n  ]\r\n  echo \\iamntz\\utils\\Tpl::get('elementor/widgets/icon-list', apply_filters('elementor/render/widgets/icon-list', $render);\r\n}\r\n```\r\n\r\nelementor/widgets/icon-list.hbs file:\r\n```hbs\r\n    <ul class=\"elementor-icon-list-items\">\r\n    {{#each items}}\r\n        <li class=\"elementor-icon-list-item\" >\r\n          {{#if link.url}}\r\n            <a href=\"{{ link.url }}\">\r\n          {{/if}}\r\n            {{#if icon}}\r\n              <span class=\"elementor-icon-list-icon\">\r\n                <i class=\"{{ icon }}\"></i>\r\n              </span>\r\n            {{/if}}\r\n\r\n            <span class=\"elementor-icon-list-text\">{{ text }}</span>\r\n\r\n          {{#if link.url}}\r\n            </a>\r\n          {{/if}}\r\n        </li>\r\n    {{/each}}\r\n    </ul>\r\n```\r\n\r\nHere, you will be able to:\r\n1. apply a filter over the rendered data\r\n1. easily replace the template file\r\n1. clean things and made them _very_ readable\r\n\r\n---\r\n\r\n¹ It can be any simple, logicless template engine though."}}
{"actor":{"display_login":"iamntz"}}