2582 Commits

Author SHA1 Message Date
René Kijewski
988b643c20 derive: dedupe visit custom filters code 2025-06-01 23:56:10 +02:00
Michael Pollind
df54534ae6 bugfix: resolve with macro with call after caller
https://github.com/askama-rs/askama/issues/467

Signed-off-by: Michael Pollind <mpollind@gmail.com>
2025-06-01 21:05:06 +02:00
René Kijewski
0e30499f59 ci: update fuzzing corpus to include derive 2025-06-01 19:14:28 +02:00
René Kijewski
ca50787f92 parser: macro calls need proper tokens
With this PR invalid tokens inside a macro call `macro_name!(..)` are
rejected. Otherwise we might emit invalid code that cannot be parsed by
rust.
2025-06-01 19:14:28 +02:00
Guillaume Gomez
6010cd390f Add documentation for mutable variables 2025-06-01 16:26:57 +02:00
Guillaume Gomez
741ff53a88 Add regression tests for mutable variables 2025-06-01 16:26:57 +02:00
Guillaume Gomez
9ee2afecfa Add support for mutable variables 2025-06-01 16:26:57 +02:00
strickczq
c40e828f03 fix fmt and clippy 2025-05-29 19:00:50 +02:00
strickczq
77b0763679 Track first line across calls and add tests
Fix logic issue where `self.first` was not tracked across calls, causing incorrect indentation.

Replaced `idx` with `is_first_line` flag.

Added `test_indent_chunked` to verify correct behavior.
2025-05-29 19:00:50 +02:00
strickczq
6653662d9e book: remove alloc feature mention for indent filter
Updated the "filters" chapter in the book to remove the mention of the alloc feature requirement for the indent filter, as it no longer relies on memory allocation.
2025-05-29 19:00:50 +02:00
strickczq
6d5473f801 fix alloc imports by indent.rs 2025-05-29 19:00:50 +02:00
strickczq
b54c5666c3 Move indent filter to separate indent.rs file
Relocated the `indent` filter implementation from alloc.rs to a new indent.rs file,
as it no longer requires memory allocation.

Updated module imports and exports in filters/mod.rs to reflect this change.

Removed unused dependencies
    (Cow, Deref, Pin) from alloc.rs.
2025-05-29 19:00:50 +02:00
strickczq
8c6d227ddb Rewrite indent filter to use IndentWriter
Refactored the `indent` filter implementation to introduce the `IndentWriter` struct,
eliminating the need for memory allocation.

Removed the `MAX_LEN` restriction and the `fuzzed_indent_filter` test,
as they are no longer necessary with the new approach.

Fixes #465.
2025-05-29 19:00:50 +02:00
Alexander Zaitsev
08682a3133
docs: Update performance.md (#188)
* docs: Update performance.md

- add documentation about PGO usage for optimizing Rinja's performance
2025-05-28 11:39:03 +02:00
Guillaume Gomez
39b957a1b3 Add issue templates 2025-05-28 03:17:01 +02:00
Guillaume Gomez
f3201cfb21
Merge pull request #456 from sinder38/update-ref-doc
Update `ref` documentation
2025-05-26 22:04:05 +02:00
René Kijewski
429aaf0821 Escape macro names like loop! 2025-05-23 21:01:00 +02:00
René Kijewski
377253945e crate! etc are invalid macro names 2025-05-23 21:01:00 +02:00
Guillaume Gomez
657dcea10f
Merge pull request #422 from pollend/feature/add-support-for-caller
feat: add caller pattern from jinja
2025-05-23 13:57:18 +02:00
Guillaume Gomez
a2088e730a Add missing endcall in examples 2025-05-23 12:07:22 +02:00
Guillaume Gomez
7a53f7f942
Merge pull request #457 from Kijewski/pr-comp
Comparison operators cannot be chained
2025-05-23 10:20:04 +02:00
Michael Pollind
5bbaca527d add missing endcall for examples
Signed-off-by: Michael Pollind <mpollind@gmail.com>
2025-05-22 19:35:53 -07:00
René Kijewski
eaccbb02ae Comparison operators cannot be chained 2025-05-23 01:26:19 +02:00
Guillaume Gomez
1acbc33383 Improve error output 2025-05-22 23:11:46 +02:00
Guillaume Gomez
aefd0848af Fix test_short_circuit test 2025-05-22 23:07:27 +02:00
Guillaume Gomez
06c32d6d18 Allow super in calls 2025-05-22 23:04:52 +02:00
Guillaume Gomez
3ab930ded0 Fix handling of endcall whitespace characters 2025-05-22 22:50:40 +02:00
Michael Pollind
f08ca469c9 add more test add reserved word caller
Signed-off-by: Michael Pollind <mpollind@gmail.com>
2025-05-22 22:50:40 +02:00
Michael Pollind
83057d8f30 Update askama_derive/src/generator/node.rs
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2025-05-22 22:50:40 +02:00
Michael Pollind
c4fcd4781a address comments
Signed-off-by: Michael Pollind <mpollind@gmail.com>
2025-05-22 22:50:40 +02:00
Michael Pollind
0547c2ee88 fix caller logic
Signed-off-by: Michael Pollind <mpollind@gmail.com>
2025-05-22 22:50:40 +02:00
Michael Pollind
b328a96ca4 simplify handler
Signed-off-by: Michael Pollind <mpollind@gmail.com>
2025-05-22 22:50:40 +02:00
Michael Pollind
ef489b60f6 add test cases and rework spaces
Signed-off-by: Michael Pollind <mpollind@gmail.com>
2025-05-22 22:50:40 +02:00
Michael Pollind
8862325e9b tweak test
Signed-off-by: Michael Pollind <mpollind@gmail.com>
2025-05-22 22:50:40 +02:00
Michael Pollind
5c07ea6842 address comments
Signed-off-by: Michael Pollind <mpollind@gmail.com>
2025-05-22 22:50:40 +02:00
Michael Pollind
7370f951a1 Update book/src/template_syntax.md
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2025-05-22 22:50:40 +02:00
Michael Pollind
c88c4015d9 Update book/src/template_syntax.md
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2025-05-22 22:50:40 +02:00
Michael Pollind
ce73e73720 feat: add caller pattern and adjust syntax to closer match jinja
Signed-off-by: Michael Pollind <mpollind@gmail.com>
2025-05-22 22:50:40 +02:00
Michael Pollind
9215884c1a add docs
Signed-off-by: Michael Pollind <mpollind@gmail.com>
2025-05-22 22:50:39 +02:00
Michael Pollind
b8c85a07bd feat: add caller pattern for macro
Signed-off-by: Michael Pollind <mpollind@gmail.com>
2025-05-22 22:50:39 +02:00
sinder
0ce68a32f8 Change deprecated as_ref to ref
Add a line about `ref` renaming to the upgrade guide
2025-05-22 22:46:24 +08:00
Dominique Martinet
cd13e4f148
book: upgrading: complete note about filter change (#453)
commit c6d45e1cdc0f ("Always supply `values` to custom filters") added a
second mandatory argument, and it was not obvious what broke on upgrade
through the current explanation so write a bit more about it.
2025-05-22 16:17:12 +02:00
Guillaume Gomez
bbd5285381
Merge pull request #450 from GuillaumeGomez/crate-identifier
Prevent `crate` to be used as identifier
2025-05-20 23:27:23 +02:00
René Kijewski
f92ed0a074 Deny self etc. as path element 2025-05-20 21:20:55 +02:00
René Kijewski
1b2c54620e name is its own span 2025-05-20 21:19:57 +02:00
Guillaume Gomez
5099820722 Add test to ensure that self can be used as match argument 2025-05-20 18:37:39 +02:00
Guillaume Gomez
8b05a5c118 Add ui tests for crate, Self and super as identifiers 2025-05-20 18:37:39 +02:00
Guillaume Gomez
244980e0e9 Prevent crate, Self and super to be used as identifiers 2025-05-20 18:31:08 +02:00
Guillaume Gomez
6ac39d24d9
Merge pull request #446 from Kijewski/pr-parse-source-crash
Print invalid generated code during panic
2025-05-19 16:36:03 +02:00
Guillaume Gomez
00f9c7068d
Merge pull request #448 from Kijewski/pr-int-base
derive: don't suppress fatal errors in integer parsing
2025-05-19 13:07:37 +02:00