{"action":"created","issue":{"url":"https://api.github.com/repos/roots/sage/issues/1414","repository_url":"https://api.github.com/repos/roots/sage","labels_url":"https://api.github.com/repos/roots/sage/issues/1414/labels{/name}","comments_url":"https://api.github.com/repos/roots/sage/issues/1414/comments","events_url":"https://api.github.com/repos/roots/sage/issues/1414/events","html_url":"https://github.com/roots/sage/issues/1414","id":67614334,"number":1414,"title":"Alternative to get_template_part which allows you to pass data.","user":{"login":"christianmagill","id":2133370,"avatar_url":"https://avatars3.githubusercontent.com/u/2133370?v=4","gravatar_id":"","url":"https://api.github.com/users/christianmagill","html_url":"https://github.com/christianmagill","followers_url":"https://api.github.com/users/christianmagill/followers","following_url":"https://api.github.com/users/christianmagill/following{/other_user}","gists_url":"https://api.github.com/users/christianmagill/gists{/gist_id}","starred_url":"https://api.github.com/users/christianmagill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/christianmagill/subscriptions","organizations_url":"https://api.github.com/users/christianmagill/orgs","repos_url":"https://api.github.com/users/christianmagill/repos","events_url":"https://api.github.com/users/christianmagill/events{/privacy}","received_events_url":"https://api.github.com/users/christianmagill/received_events","type":"User","site_admin":false},"labels":[{"id":176715062,"url":"https://api.github.com/repos/roots/sage/labels/enhancement","name":"enhancement","color":"bfe5bf","default":true},{"id":155003182,"url":"https://api.github.com/repos/roots/sage/labels/templates","name":"templates","color":"006b75","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":25,"created_at":"2015-04-10T14:58:29Z","updated_at":"2018-05-30T08:47:21Z","closed_at":"2015-12-30T00:50:42Z","author_association":"NONE","body":"In a lot of my projects I've started using an alternative to get_template_part that allows you to pass data. I'm wondering whether something of this ilk would be good to include with Sage.\n\nFunction\n\n<pre>\n/**\n * Load a component into a template while supplying data.\n *\n * @param string $slug The slug name for the generic template.\n * @param array $params An associated array of data that will be extracted into the templates scope\n * @param bool $output Whether to output component or return as string.\n * @return string\n */\nfunction get_component($slug, array $params = array(), $output = true) {\n    if(!$output) ob_start();\n    $template_file = locate_template(\"components/{$slug}.php\", false, false);\n    extract($params, EXTR_SKIP);\n    require($template_file);\n    if(!$output) return ob_get_clean();\n}\n</pre>\n\n"},"comment":{"url":"https://api.github.com/repos/roots/sage/issues/comments/393081509","html_url":"https://github.com/roots/sage/issues/1414#issuecomment-393081509","issue_url":"https://api.github.com/repos/roots/sage/issues/1414","id":393081509,"user":{"login":"ciromattia","id":125366,"avatar_url":"https://avatars3.githubusercontent.com/u/125366?v=4","gravatar_id":"","url":"https://api.github.com/users/ciromattia","html_url":"https://github.com/ciromattia","followers_url":"https://api.github.com/users/ciromattia/followers","following_url":"https://api.github.com/users/ciromattia/following{/other_user}","gists_url":"https://api.github.com/users/ciromattia/gists{/gist_id}","starred_url":"https://api.github.com/users/ciromattia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ciromattia/subscriptions","organizations_url":"https://api.github.com/users/ciromattia/orgs","repos_url":"https://api.github.com/users/ciromattia/repos","events_url":"https://api.github.com/users/ciromattia/events{/privacy}","received_events_url":"https://api.github.com/users/ciromattia/received_events","type":"User","site_admin":false},"created_at":"2018-05-30T08:47:21Z","updated_at":"2018-05-30T08:47:21Z","author_association":"CONTRIBUTOR","body":"In blade (Sage 9) you can simply pass variables as the second parameter without polluting the globals, like:\r\n`@include('partials.component', $componentData)`"}}
{"actor":{"display_login":"ciromattia"}}