feat: add caller pattern from jinja #422
Conversation
ced67ce to
f0cc0cb
Compare
7368ac2 to
0c47b3f
Compare
GuillaumeGomez
left a comment
There was a problem hiding this comment.
Seems like a very good and solid start! I think the syntax should allow to have default values etc, but can be done in a follow-up. For now though, please support more than just identifiers as arguments when calling it.
| source = r#" | ||
| {%- macro test() -%} | ||
| {{- caller("test") -}} | ||
| {{- caller("test") -}} |
There was a problem hiding this comment.
Maybe replace "test" with 1 for this one? Like that we cover integer literals as well. :)
|
probably need a lot more test where to start? |
|
Hard to say. ^^' I have a few ideas:
And of course, all the same with |
|
the space handling was wrong didn't understand it on the first pass. I made some more adjustments hopefully the handling is correct now. |
1f50bbb to
a70b7bc
Compare
| error: missing `c` argument | ||
| --> InvalidNumberArguments.txt:3:18 | ||
| "(\"a\", \"b\") -}}\n {%- endmacro -%}\n {%- call(a,b,c) test() -%}\n {{- a"... | ||
| --> tests/ui/caller_arguments.rs:5:14 | ||
| | | ||
| 5 | source = r#" | ||
| | ______________^ | ||
| 6 | | {% macro test() %} | ||
| 7 | | {{- caller("a", "b") -}} | ||
| 8 | | {%- endmacro -%} | ||
| ... | | ||
| 11 | | {%- endcall -%} | ||
| 12 | | "#, | ||
| | |______^ |
There was a problem hiding this comment.
this does not look quite correct it should be the call. umm, not sure how to address this.
There was a problem hiding this comment.
Strange indeed, seems like the span is created from the start of the arguments and not of caller.
|
having to wrap every macro in |
f69db26 to
aa1458c
Compare
|
I added more test cases. and addressed some problems. |
34764cf to
329aa4e
Compare
It's somewhat supported. Can be revisited though. |
Signed-off-by: Michael Pollind <mpollind@gmail.com>
Signed-off-by: Michael Pollind <mpollind@gmail.com>
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
Signed-off-by: Michael Pollind <mpollind@gmail.com>
Signed-off-by: Michael Pollind <mpollind@gmail.com>
Signed-off-by: Michael Pollind <mpollind@gmail.com>
Signed-off-by: Michael Pollind <mpollind@gmail.com>
Signed-off-by: Michael Pollind <mpollind@gmail.com>
Signed-off-by: Michael Pollind <mpollind@gmail.com>
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
Signed-off-by: Michael Pollind <mpollind@gmail.com>
4b70331 to
1acbc33
Compare
|
@Kijewski: The book build breakage is expected or is it a new dark magic bug? XD |
403 is a permission error |
|
I re-ran the test, and it works now. The download is retried up to 3 times, but I guess 1 second in between is a bit short. The examples use macros, and need to be updated, too. |
Signed-off-by: Michael Pollind <mpollind@gmail.com>
|
CI is happy. Time to merge! Thanks a lot! |
ref: #282 (comment)
I adjusted this quite heavily given the discussion in issue 282. This both adds the caller macro pattern and changes the syntax to align closer to jinja.
{% call super() %}is now{{ super() }}https://jinja.palletsprojects.com/en/stable/templates/#call
https://jinja.palletsprojects.com/en/stable/templates/#child-template