RexOps / RexOps/Rex

RFC: Template using PadWalker to access variables from inside task

Open
#833 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement question
Dominant language
Perl
Stars
737
Forks
214
PR merge metrics
No merged PRs in 30d

Description

Hi,

it 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:

task "mytask", sub {
  my $x = 5;
  file "/tmp/foo.txt", content => template("mytemplate.tpl");
};
# the template
counter: <%=  $x %>

So 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.

What do you think about this?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review how task callbacks invoke template() and how template variables are currently passed. Evaluate the PadWalker proposal and its implications for accessing task-local variables. Done would require an agreed design and maintainer decision on whether templates should support this behavior without explicit variable passing.

Written by the indexing model from the issue text.

Assessment

Tech stack
perl
Domain
devops
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.