{"action":"created","issue":{"url":"https://api.github.com/repos/zordius/lightncandy/issues/251","repository_url":"https://api.github.com/repos/zordius/lightncandy","labels_url":"https://api.github.com/repos/zordius/lightncandy/issues/251/labels{/name}","comments_url":"https://api.github.com/repos/zordius/lightncandy/issues/251/comments","events_url":"https://api.github.com/repos/zordius/lightncandy/issues/251/events","html_url":"https://github.com/zordius/lightncandy/issues/251","id":198352245,"number":251,"title":"Dynamically resolved helpers don't work from partials","user":{"login":"markkimsal","id":54099,"avatar_url":"https://avatars.githubusercontent.com/u/54099?v=3","gravatar_id":"","url":"https://api.github.com/users/markkimsal","html_url":"https://github.com/markkimsal","followers_url":"https://api.github.com/users/markkimsal/followers","following_url":"https://api.github.com/users/markkimsal/following{/other_user}","gists_url":"https://api.github.com/users/markkimsal/gists{/gist_id}","starred_url":"https://api.github.com/users/markkimsal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markkimsal/subscriptions","organizations_url":"https://api.github.com/users/markkimsal/orgs","repos_url":"https://api.github.com/users/markkimsal/repos","events_url":"https://api.github.com/users/markkimsal/events{/privacy}","received_events_url":"https://api.github.com/users/markkimsal/received_events","type":"User","site_admin":false},"labels":[{"id":24707136,"url":"https://api.github.com/repos/zordius/lightncandy/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"closed","locked":false,"assignee":{"login":"zordius","id":1201409,"avatar_url":"https://avatars.githubusercontent.com/u/1201409?v=3","gravatar_id":"","url":"https://api.github.com/users/zordius","html_url":"https://github.com/zordius","followers_url":"https://api.github.com/users/zordius/followers","following_url":"https://api.github.com/users/zordius/following{/other_user}","gists_url":"https://api.github.com/users/zordius/gists{/gist_id}","starred_url":"https://api.github.com/users/zordius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zordius/subscriptions","organizations_url":"https://api.github.com/users/zordius/orgs","repos_url":"https://api.github.com/users/zordius/repos","events_url":"https://api.github.com/users/zordius/events{/privacy}","received_events_url":"https://api.github.com/users/zordius/received_events","type":"User","site_admin":false},"assignees":[{"login":"zordius","id":1201409,"avatar_url":"https://avatars.githubusercontent.com/u/1201409?v=3","gravatar_id":"","url":"https://api.github.com/users/zordius","html_url":"https://github.com/zordius","followers_url":"https://api.github.com/users/zordius/followers","following_url":"https://api.github.com/users/zordius/following{/other_user}","gists_url":"https://api.github.com/users/zordius/gists{/gist_id}","starred_url":"https://api.github.com/users/zordius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zordius/subscriptions","organizations_url":"https://api.github.com/users/zordius/orgs","repos_url":"https://api.github.com/users/zordius/repos","events_url":"https://api.github.com/users/zordius/events{/privacy}","received_events_url":"https://api.github.com/users/zordius/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/zordius/lightncandy/milestones/8","html_url":"https://github.com/zordius/lightncandy/milestone/8","labels_url":"https://api.github.com/repos/zordius/lightncandy/milestones/8/labels","id":2224224,"number":8,"title":"1.0.1","description":null,"creator":{"login":"zordius","id":1201409,"avatar_url":"https://avatars.githubusercontent.com/u/1201409?v=3","gravatar_id":"","url":"https://api.github.com/users/zordius","html_url":"https://github.com/zordius","followers_url":"https://api.github.com/users/zordius/followers","following_url":"https://api.github.com/users/zordius/following{/other_user}","gists_url":"https://api.github.com/users/zordius/gists{/gist_id}","starred_url":"https://api.github.com/users/zordius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zordius/subscriptions","organizations_url":"https://api.github.com/users/zordius/orgs","repos_url":"https://api.github.com/users/zordius/repos","events_url":"https://api.github.com/users/zordius/events{/privacy}","received_events_url":"https://api.github.com/users/zordius/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":1,"state":"open","created_at":"2017-01-03T01:36:20Z","updated_at":"2017-01-03T08:29:45Z","due_on":null,"closed_at":null},"comments":5,"created_at":"2017-01-02T15:50:45Z","updated_at":"2017-01-03T08:53:51Z","closed_at":"2017-01-03T08:29:45Z","body":"The PHP Code:\r\n-------------\r\n\r\n```php\r\nrequire('./vendor/autoload.php');\r\nuse LightnCandy\\LightnCandy;\r\n\r\n// Non-working template:\r\n$template = <<<VAREND\r\n{{>baz}}\r\nVAREND;\r\n\r\n//working template\r\n/*\r\n$template = <<<VAREND\r\n{{someUndefHelper abc='foo'}}\r\nVAREND;\r\n*/\r\n\r\n// Partials:\r\n$partials = array(\r\n    'baz' => 'Yes, partial  {{someUndefHelper abc=\\'foo\\'}}',\r\n);\r\n\r\nfunction someUndefHelper($options) { \r\nreturn \"bar\";\r\n}\r\n    \r\n$phpStr = LightnCandy::compile($template, array(\r\n  // Used compile flags\r\n  'flags' => LightnCandy::FLAG_ERROR_EXCEPTION | LightnCandy::FLAG_HANDLEBARS |\r\n            LightnCandy::FLAG_RUNTIMEPARTIAL |\r\n            LightnCandy::FLAG_EXTHELPER |\r\n            LightnCandy::FLAG_HANDLEBARSJS,\r\n            \r\n  'partials' => $partials,\r\n  'helperresolver'=> function(&$cx, $name) {\r\n    if (array_key_exists($name,  $cx['helpers'])) {\r\n        return;\r\n    }   \r\n    //$cx['helpers'][$name] = $name;\r\n    return $name;\r\n  } \r\n)); \r\n\r\necho \"Generated PHP Code:\\n$phpStr\\n\";\r\n\r\n// Input Data:\r\n$data = array(\r\n  'qoo' => 'moo'\r\n);\r\n\r\n// Save the compiled PHP code into a php file\r\nfile_put_contents('render.php', '<?php ' . $phpStr . '?>');\r\n\r\n// Get the render function from the php file\r\n$renderer = include('render.php');\r\n\r\necho \"Result:\\n\" . $renderer($data);\r\n```\r\n\r\n\r\nThe Issue:\r\n----------\r\n\r\nHelpers resolved with a helperresolver that appear only in partials do not end up in the context's helpers array, but they do end up in the usageCount -> helpers array.\r\n\r\nCalling {{someUndefHelper}} from the main template works, but calling it only from the partial doesn't create a reference in the helpers array in the compiled code.\r\n"},"comment":{"url":"https://api.github.com/repos/zordius/lightncandy/issues/comments/270071266","html_url":"https://github.com/zordius/lightncandy/issues/251#issuecomment-270071266","issue_url":"https://api.github.com/repos/zordius/lightncandy/issues/251","id":270071266,"user":{"login":"jayS-de","id":10562872,"avatar_url":"https://avatars.githubusercontent.com/u/10562872?v=3","gravatar_id":"","url":"https://api.github.com/users/jayS-de","html_url":"https://github.com/jayS-de","followers_url":"https://api.github.com/users/jayS-de/followers","following_url":"https://api.github.com/users/jayS-de/following{/other_user}","gists_url":"https://api.github.com/users/jayS-de/gists{/gist_id}","starred_url":"https://api.github.com/users/jayS-de/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jayS-de/subscriptions","organizations_url":"https://api.github.com/users/jayS-de/orgs","repos_url":"https://api.github.com/users/jayS-de/repos","events_url":"https://api.github.com/users/jayS-de/events{/privacy}","received_events_url":"https://api.github.com/users/jayS-de/received_events","type":"User","site_admin":false},"created_at":"2017-01-03T08:53:51Z","updated_at":"2017-01-03T08:53:51Z","body":"Works 👍 "}}
{"actor":{"display_login":"jayS-de"}}