fmartingr
/
jeeves
Archived
1
0
Fork 0

template action expose rendered file in result output

This commit is contained in:
Felipe Martin 2020-05-09 21:07:17 +02:00
parent 385aef856e
commit 621b0555d2
Signed by: fmartingr
GPG Key ID: 716BC147715E716F
1 changed files with 4 additions and 2 deletions

View File

@ -31,13 +31,15 @@ class TemplateAction(Action):
def execute(self, **kwargs):
workspace = kwargs.get("workspace")
arguments = kwargs.get("arguments")
execution = kwargs.get("execution")
source_path = os.path.join(os.getcwd(), self.parameters.src)
assert os.path.exists(source_path), "Source template does not exist"
template = Template(open(source_path, "r").read())
rendered = template.render(current_execution=execution, **arguments)
with open(os.path.join(workspace.path, self.parameters.dest), "w") as handler:
handler.write(template.render(**arguments))
handler.write(rendered)
return Result(success=True)
return Result(success=True, output=rendered)