Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
fix: Perform empty init command on startup of renderer
Browse files Browse the repository at this point in the history
This avoids partially initialized renderers being closed too early.
  • Loading branch information
codablock committed Jan 8, 2024
1 parent 555634c commit 90d67f0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions jinja2_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ func newPythonJinja2Renderer(j2 *Jinja2) (*pythonJinja2Renderer, error) {

j2r.stdoutReader = bufio.NewReader(j2r.stdout)

_, err = j2r.runCmd(&jinja2Cmd{
Cmd: "init",
})
if err != nil {
return nil, fmt.Errorf("failed to initialize renderer: %w", err)
}

isOk = true

return j2r, nil
Expand Down
4 changes: 3 additions & 1 deletion python_src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def main():
r = Jinja2Renderer(opts)

result = {}
if cmd["cmd"] == "render-strings":
if cmd["cmd"] == "init":
pass
elif cmd["cmd"] == "render-strings":
result = {
"templateResults": r.RenderStrings(cmd["templates"])
}
Expand Down

0 comments on commit 90d67f0

Please sign in to comment.