Commit 47405e7
committed
Explicitly fail by creating a deferred node when attempting to defer modification of an alias outside of the context of an import.
This is a niche situation that we'd rather explicitly fail on than have incorrect logic. Handling this correctly is complex and likely not worth it.
Example:
```
{# 'eager/settings.jinja' #}
{% set settings = {} %}
{% macro load_settings() %}
{% do settings.put('foo', 'bar') %}
{% endmacro %}
```
```
{# 'main.jinja' #}
{% import 'eager/settings.jinja' as shared %}
{% if deferred %}
{{ shared.load_settings() }}
{% endif %}
{{ shared.settings }}
```1 parent fbdaf83 commit 47405e7
8 files changed
Lines changed: 27 additions & 25 deletions
File tree
- src
- main/java/com/hubspot/jinjava/lib
- fn/eager
- tag/eager
- importing
- test
- java/com/hubspot/jinjava
- lib/tag/eager
- resources/eager
Lines changed: 1 addition & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | 74 | | |
84 | 75 | | |
85 | 76 | | |
| |||
303 | 294 | | |
304 | 295 | | |
305 | 296 | | |
306 | | - | |
| 297 | + | |
307 | 298 | | |
308 | 299 | | |
309 | 300 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
166 | 167 | | |
167 | 168 | | |
168 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
169 | 175 | | |
170 | 176 | | |
171 | 177 | | |
| |||
Lines changed: 11 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
119 | | - | |
120 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
121 | 129 | | |
122 | 130 | | |
123 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1501 | 1501 | | |
1502 | 1502 | | |
1503 | 1503 | | |
1504 | | - | |
1505 | | - | |
1506 | | - | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
1507 | 1507 | | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
1508 | 1511 | | |
1509 | 1512 | | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
347 | | - | |
| 347 | + | |
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
| |||
355 | 355 | | |
356 | 356 | | |
357 | 357 | | |
358 | | - | |
| 358 | + | |
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
| |||
Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
0 commit comments