488 Commits

Author SHA1 Message Date
Guillaume Gomez
7947cdcafb Fix ui test 2025-01-12 19:43:39 +01:00
Guillaume Gomez
8d6279d9c8
Merge pull request #279 from GuillaumeGomez/block_in_include
Fix `block_in_include` and add explanations on what is going on
2025-01-01 12:15:33 +01:00
René Kijewski
d254942dbc Add jinja2 tests to verify that jinja2 renders the same 2025-01-01 09:31:52 +01:00
René Kijewski
9336435859 derive: keep track of called macros
Recursive macro calls, direct and indirect, would cause a stackoverflow.

This PR lets the macro call handler keep track of the stack of called
macros we are currently in, so we can abort with an error message
instead of panicking.
2024-12-29 07:52:21 +01:00
René Kijewski
4b8bd45844 parser: use drop guards to track nesting level
Not for all operations the nesting level was incremented when needed
and/or the un-incremented nesting level was used in subfunction calls.
Binary operators such as `*` did not properly increment the nesting
level.

This PR changes `Level` in such a way that it can be used to keep track
of the nesting level when used in a loop. It is now impossible to
accidentally refer to an old nesting level value.

Resolves <https://issues.oss-fuzz.com/issues/385256115>.
2024-12-27 04:31:24 +01:00
Guillaume Gomez
8a20caa136 Fix block_in_include and add explanations on what is going on 2024-12-22 21:11:04 +01:00
René Kijewski
18f1d9b343 parser: deny rust 2024 keyword gen as target name 2024-12-21 23:50:13 +01:00
René Kijewski
c80e78e8b5 parser: deny all rust keywords as target names 2024-12-21 23:49:48 +01:00
Guillaume Gomez
0d91bee794 Update ui tests 2024-12-21 23:06:56 +01:00
René Kijewski
0cc0189927 Add missing softlinks 2024-12-21 19:55:15 +01:00
René Kijewski
e800b7ca90 derive: reserve variable prefix __rinja and free name writer 2024-12-21 19:42:03 +01:00
René Kijewski
fe36573926 Let operator ? only wrap the error in Box if needed
This leads to fewer needless allocations, and makes the operator `?`
usable in an no-alloc context.
2024-12-21 18:53:44 +01:00
René Kijewski
bedc31797c Make #![no_std] compatible 2024-12-21 18:53:44 +01:00
René Kijewski
74bf996ff3 derive: update expected output for newer trybuild versions 2024-12-16 11:46:16 +01:00
Luca Palmieri
f0ac41df30 Reproduce bug with a test 2024-12-15 12:07:11 +01:00
René Kijewski
42b4a1c272 derive: fix typo to not print whole rem file on error 2024-12-13 02:54:43 +01:00
René Kijewski
430b99bdac Fix clippy warnings in rust nightly 1.85 2024-12-11 19:50:29 +01:00
René Kijewski
e08c28c126 Only run UI tests on stable rust 2024-12-11 19:50:29 +01:00
René Kijewski
66dac1df06 Add failing test from issue 272
Reported by Ciprian Dorin Craciun ([@cipriancraciun]) in issue [#272].

[#272]: <https://github.com/rinja-rs/rinja/issues/272>
[@cipriancraciun]: <https://github.com/cipriancraciun>
2024-11-26 07:23:37 +01:00
René Kijewski
50f50e3931 derive: a safe-guard to disable bindings a unit struct was expected
This does not fix the error, as rinja is not able to tell was the
actually intended to do, but rust gives you a guide what the error is,
and the error is not silently ignored.
2024-11-24 19:06:47 +01:00
René Kijewski
e2515bdacb derive: reword in_doc error message if code block is absent 2024-11-24 01:08:51 +01:00
René Kijewski
277cdb4f87 derive: PartialTemplateArgs actually does not need keep track of the argument keys 2024-11-24 01:08:51 +01:00
Guillaume Gomez
07e6216e83 Allow variables to be inherited in blocks 2024-11-22 18:44:42 +01:00
chrisp60
0018b3bf77 fix: normalize macro args on call #259 2024-11-21 08:58:11 -05:00
Guillaume Gomez
8dbbb9ae48 Allow to create variables named _ 2024-11-20 14:55:05 +01:00
Guillaume Gomez
7aa8868b29 Extend checks for underscore ident misuses 2024-11-19 21:21:54 +01:00
Guillaume Gomez
f39a846598 Allow idents to start with _ 2024-11-19 18:10:06 +01:00
René Kijewski
968b80fcb8 Remove EXTENSION constant from Template
I doubt that is needed in any circumstance, and it makes implementing
enum variants harder.
2024-11-18 16:55:30 +01:00
René Kijewski
26f6808aa6 derive: fix typos and unify error messages 2024-11-18 15:43:16 +01:00
Guillaume Gomez
f3cff091b7
Merge pull request #250 from GuillaumeGomez/filters
Remove restriction preventing to have | surrounded by whistespace characters
2024-11-18 15:28:26 +01:00
Guillaume Gomez
d7bc44a87d Remove restriction preventing to have | surrounded by whistespace characters 2024-11-17 20:25:01 +01:00
Guillaume Gomez
b0d834c0fd Improve error message when an extension escaper is missing 2024-11-15 15:02:10 +01:00
René Kijewski
ebdd3f8b43 parser: allow whitespace control on extends 2024-11-14 16:53:14 +01:00
René Kijewski
d3b9b6ea56 Raise MSRV to 1.80 2024-11-13 23:33:06 +01:00
René Kijewski
c5ed6af5a3 parser: add better error messages for broken closing block tags 2024-11-13 20:14:42 +01:00
René Kijewski
e7f5de2697 Add garbled closing block test 2024-11-13 20:03:08 +01:00
René Kijewski
7f9c91de0b Add concat operator ~
The string concatenation operator `~` is present in jinja and tera:
<https://jinja.palletsprojects.com/en/stable/templates/#other-operators>.
While it's not the most important operator, it can come in handy e.g.
with filters: `{{ a|upper }}{{ b|upper }}` → `{{ (a ~ b)|upper }}`.
2024-11-12 17:07:17 +01:00
René Kijewski
3e07719ad9 derive: reject unions as they require unsafe code 2024-11-11 00:55:47 +01:00
René Kijewski
fe551596f3 unions generate invalid code 2024-11-11 00:42:08 +01:00
Guillaume Gomez
6e13c81a5f Move types into their tests 2024-11-09 22:22:42 +01:00
Guillaume Gomez
e98cfa9ce8
Merge pull request #207 from GuillaumeGomez/macro-default-value
Add support for default value in macros
2024-11-09 19:18:49 +08:00
René Kijewski
19db2765b7 parser: more strict macro argument parsing 2024-11-09 08:37:54 +01:00
René Kijewski
84b76ac966 Add HtmlSafe reference wrapper tests 2024-11-03 00:37:06 +01:00
Guillaume Gomez
c87be3ec36 Relax rules for filesizeformat filter
Remove `humansize` dependency
2024-11-01 00:51:03 +01:00
Guillaume Gomez
6df0892d1a Make it possible to use macro arguments as default value 2024-10-25 23:24:11 +02:00
Guillaume Gomez
cf0d821b9e Add code generation for default value arguments 2024-10-25 23:21:05 +02:00
René Kijewski
3cb337255b Bump version number to v0.3.5
We gathered quiet a few changes in the last month:
<https://github.com/rinja-rs/rinja/compare/v0.3.4...1e319fd0c869884b68c9287bc4bcb1309b16328e>
2024-10-23 15:10:15 +02:00
Guillaume Gomez
1e319fd0c8
Merge pull request #200 from Kijewski/pr-ref
Unify trait impl for reference wrapper types
2024-10-23 21:03:35 +08:00
Guillaume Gomez
c77cd37821 Add regression test for config delimiters 2024-10-20 05:06:06 +02:00
René Kijewski
f7d1e9a5b4 Unify trait impl for reference wrapper types
This changes makes sure that no implementation is forgotten and
deduplicates some code.
2024-10-16 21:46:59 +02:00