{"action":"created","issue":{"url":"https://api.github.com/repos/RexOps/Rex/issues/833","labels_url":"https://api.github.com/repos/RexOps/Rex/issues/833/labels{/name}","comments_url":"https://api.github.com/repos/RexOps/Rex/issues/833/comments","events_url":"https://api.github.com/repos/RexOps/Rex/issues/833/events","html_url":"https://github.com/RexOps/Rex/issues/833","id":117089878,"number":833,"title":"RFC: Template using PadWalker to access variables from inside task","user":{"login":"krimdomu","id":388436,"avatar_url":"https://avatars.githubusercontent.com/u/388436?v=3","gravatar_id":"","url":"https://api.github.com/users/krimdomu","html_url":"https://github.com/krimdomu","followers_url":"https://api.github.com/users/krimdomu/followers","following_url":"https://api.github.com/users/krimdomu/following{/other_user}","gists_url":"https://api.github.com/users/krimdomu/gists{/gist_id}","starred_url":"https://api.github.com/users/krimdomu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krimdomu/subscriptions","organizations_url":"https://api.github.com/users/krimdomu/orgs","repos_url":"https://api.github.com/users/krimdomu/repos","events_url":"https://api.github.com/users/krimdomu/events{/privacy}","received_events_url":"https://api.github.com/users/krimdomu/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/RexOps/Rex/labels/enhancement","name":"enhancement","color":"bfe5bf"},{"url":"https://api.github.com/repos/RexOps/Rex/labels/question","name":"question","color":"DDDDDD"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-11-16T10:09:39Z","updated_at":"2015-11-17T12:38:36Z","closed_at":null,"body":"Hi,\r\n\r\nit would be possible with the PadWalker Module (https://metacpan.org/pod/PadWalker) to get the variables that the user declared inside a task. With this it would be possible to the something like this:\r\n\r\n```perl\r\ntask \"mytask\", sub {\r\n  my $x = 5;\r\n  file \"/tmp/foo.txt\", content => template(\"mytemplate.tpl\");\r\n};\r\n```\r\n\r\n```\r\n# the template\r\ncounter: <%=  $x %>\r\n```\r\n\r\nSo it would be possible to access the variables from inside a task in the template that gets parsed in the task. With this the user doesn't need to pass the variables to the template function.\r\n\r\nWhat do you think about this?"},"comment":{"url":"https://api.github.com/repos/RexOps/Rex/issues/comments/157361072","html_url":"https://github.com/RexOps/Rex/issues/833#issuecomment-157361072","issue_url":"https://api.github.com/repos/RexOps/Rex/issues/833","id":157361072,"user":{"login":"reneeb","id":144096,"avatar_url":"https://avatars.githubusercontent.com/u/144096?v=3","gravatar_id":"","url":"https://api.github.com/users/reneeb","html_url":"https://github.com/reneeb","followers_url":"https://api.github.com/users/reneeb/followers","following_url":"https://api.github.com/users/reneeb/following{/other_user}","gists_url":"https://api.github.com/users/reneeb/gists{/gist_id}","starred_url":"https://api.github.com/users/reneeb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reneeb/subscriptions","organizations_url":"https://api.github.com/users/reneeb/orgs","repos_url":"https://api.github.com/users/reneeb/repos","events_url":"https://api.github.com/users/reneeb/events{/privacy}","received_events_url":"https://api.github.com/users/reneeb/received_events","type":"User","site_admin":false},"created_at":"2015-11-17T12:38:36Z","updated_at":"2015-11-17T12:38:36Z","body":"I use PadWalker in production code. Not very often, but sometimes it's really handy...\r\n\r\nIMHO this is a feature that should be enabled explicitly and needs lots of tests..."}}