inducer / inducer/relate

Jinja expansion rules should be the same in included templates as at the top level

Open
#130 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
435
Forks
124
Avg merge
5h 40m
Merged PRs (30d)
14

Description

Currently, the following is true:
- In top-level files (such as `flow/*.yml`), only Jinja that is not inside of a YAML block literal is expanded:

```
{{ gets_expanded }}
yoink: |
{{ does_not_get_expanded }}
```

If the block literal contains markup, a second round of Jinja expansion is then
done on the block. This is done since Jinja is not very good at maintaining
indentation, and so it would be easy for Jinja-expanded text (at the YAML level) to "burst out"
of the block literal.
- In included files, Jinja gets expanded everywhere:

```
{{ gets_expanded }}
yoink: |
{{ gets_expanded }}
```

(because the code grew that way)

This is weirdly inconsistent. I now know how to write code that treats both
cases the same (the same as top-level), but this breaks existing content. One
thing specifically that gets broken is macro files that do the following:

```
{% macro hw_header(nr) %}

description: |
blah {{ nr }}

{% endmacro %}
```

(because the `{{ nr }}` doesn't get expanded during YAML-level Jinja expansion, when `{{nr}}` is known.)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the Jinja expansion paths for top-level files such as flow/*.yml and included files, then compare them with the macro example in the issue. Done means the expansion rules are consistent while the documented compatibility impact on macro files is resolved and covered by the relevant existing tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.