130 Commits

Author SHA1 Message Date
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
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
b8c85a07bd feat: add caller pattern for macro
Signed-off-by: Michael Pollind <mpollind@gmail.com>
2025-05-22 22:50:39 +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
244980e0e9 Prevent crate, Self and super to be used as identifiers 2025-05-20 18:31:08 +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
René Kijewski
359da68fa0 derive: don't suppress fatal errors in integer parsing 2025-05-19 11:59:37 +02:00
René Kijewski
75dd2c92f3 Update dependencies
* Update version-incompatible dependencies in examples.
* Update version-incompatible dev-dependencies.
* Replaced deprecated `criterion::black_box`.
* Add `features = "simd"` to `winnow`. This adds a transitive
  dependency to `memchr`, on which we already depend on directly.
2025-05-18 23:06:41 +02:00
René Kijewski
3775f4e3a3 Use unicode-ident to determine what is an identifier
Resolves <https://github.com/askama-rs/askama/issues/442>.

The performance is actually slightly better than before. `unicode-ident`
is highly optimized and jump free.

One test from a fuzzer outcome had to be deleted, because it contained
identifiers that weren't actually identifiers. There is still a test
that tests the same problem, but every identifier is simply `x`. In
another fuzzed test a character [`U+E0049`] was removed.

[`U+E0049`]: https://en.wikipedia.org/w/index.php?oldid=1278382889

<details>
<summary>Benchmark results</summary>

```text
$ cd askama_parser && cargo bench

librustdoc/all          time:   [184.47 µs 185.30 µs 186.08 µs]
                        thrpt:  [75.887 MiB/s 76.207 MiB/s 76.548 MiB/s]
                 change:
                        time:   [−1.4364% −0.9672% −0.4738%] (p = 0.00 < 0.05)
                        thrpt:  [+0.4761% +0.9767% +1.4573%]
                        Change within noise threshold.

librustdoc/item_info    time:   [3.3880 µs 3.3892 µs 3.3906 µs]
                        thrpt:  [46.409 MiB/s 46.428 MiB/s 46.445 MiB/s]
                 change:
                        time:   [−3.8735% −3.5927% −3.2949%] (p = 0.00 < 0.05)
                        thrpt:  [+3.4071% +3.7266% +4.0296%]
                        Performance has improved.

librustdoc/item_union   time:   [20.052 µs 20.087 µs 20.126 µs]
                        thrpt:  [49.044 MiB/s 49.140 MiB/s 49.224 MiB/s]
                 change:
                        time:   [−2.2419% −1.8647% −1.5113%] (p = 0.00 < 0.05)
                        thrpt:  [+1.5345% +1.9002% +2.2933%]
                        Performance has improved.

librustdoc/page         time:   [85.828 µs 86.157 µs 86.518 µs]
                        thrpt:  [71.571 MiB/s 71.871 MiB/s 72.147 MiB/s]
                 change:
                        time:   [−1.2728% −0.7668% −0.2512%] (p = 0.00 < 0.05)
                        thrpt:  [+0.2518% +0.7727% +1.2892%]
                        Change within noise threshold.

librustdoc/print_item   time:   [10.065 µs 10.101 µs 10.138 µs]
                        thrpt:  [93.132 MiB/s 93.469 MiB/s 93.806 MiB/s]
                 change:
                        time:   [−3.3793% −2.8352% −2.3267%] (p = 0.00 < 0.05)
                        thrpt:  [+2.3821% +2.9180% +3.4975%]
                        Performance has improved.

librustdoc/short_item_info
                        time:   [9.0741 µs 9.1018 µs 9.1377 µs]
                        thrpt:  [99.148 MiB/s 99.540 MiB/s 99.843 MiB/s]
                 change:
                        time:   [−4.7480% −4.2335% −3.7763%] (p = 0.00 < 0.05)
                        thrpt:  [+3.9245% +4.4207% +4.9847%]
                        Performance has improved.

librustdoc/sidebar      time:   [21.468 µs 21.555 µs 21.648 µs]
                        thrpt:  [57.004 MiB/s 57.252 MiB/s 57.482 MiB/s]
                 change:
                        time:   [−3.7641% −3.0465% −2.4191%] (p = 0.00 < 0.05)
                        thrpt:  [+2.4791% +3.1423% +3.9114%]
                        Performance has improved.

librustdoc/source       time:   [7.9602 µs 7.9780 µs 7.9929 µs]
                        thrpt:  [92.230 MiB/s 92.403 MiB/s 92.609 MiB/s]
                 change:
                        time:   [−1.6386% −1.0684% −0.5875%] (p = 0.00 < 0.05)
                        thrpt:  [+0.5910% +1.0799% +1.6659%]
                        Change within noise threshold.

librustdoc/type_layout_size
                        time:   [4.7821 µs 4.7915 µs 4.8017 µs]
                        thrpt:  [56.406 MiB/s 56.526 MiB/s 56.637 MiB/s]
                 change:
                        time:   [−1.9743% −1.4867% −1.0153%] (p = 0.00 < 0.05)
                        thrpt:  [+1.0257% +1.5091% +2.0141%]
                        Performance has improved.

librustdoc/type_layout  time:   [15.022 µs 15.051 µs 15.076 µs]
                        thrpt:  [178.57 MiB/s 178.88 MiB/s 179.22 MiB/s]
                 change:
                        time:   [−1.5028% −1.0358% −0.5705%] (p = 0.00 < 0.05)
                        thrpt:  [+0.5738% +1.0466% +1.5257%]
                        Change within noise threshold.
```
</details>
2025-05-18 23:04:47 +02:00
René Kijewski
ab798e2482 Allow filters with explicit path
IMHO that makes custom filters much easier to use.
2025-05-17 13:20:54 +02:00
René Kijewski
72bbe3ede1 Bump version number to v0.14.0 2025-04-22 23:37:23 +02:00
Guillaume Gomez
6a16256f24 Fix new clippy lints 2025-04-22 11:34:55 +02:00
Guillaume Gomez
04a4d5b020 Update MSRV to 1.83 2025-04-22 11:34:55 +02:00
René Kijewski
b402936db3 generator: add named arguments for filters 2025-04-21 23:11:24 +02:00
René Kijewski
697862a76c Bump version number to 0.13.0 2025-03-27 17:22:37 +01:00
René Kijewski
19f6582308 Bump version number to v0.13.0-pre.0 2025-03-17 21:32:27 +01:00
Guillaume Gomez
3b52c907c3 Rename rinja into askama 2025-03-11 19:31:06 +01:00
Guillaume Gomez
2d80cc3524 Rename everything to rinja 2024-06-17 15:58:52 +02:00
Dirkjan Ochtman
1170d54c3b parser: improve parse error structure 2024-06-07 12:12:15 +02:00
Guillaume Gomez
34f84dc10f
Add support for elif (#1057)
Co-authored-by: René Kijewski <rene.kijewski@fu-berlin.de>
2024-05-23 14:27:42 +02:00
Dirkjan Ochtman
627d58bc3b parser: simplify ErrorContext construction 2024-05-21 11:26:21 +02:00
Dirkjan Ochtman
c3582f5d89 parser: attach unclosed error creation to ErrorContext 2024-05-21 11:26:21 +02:00
Dirkjan Ochtman
cbe8ac3c9e parser: order inherent impl before trait impls 2024-05-21 11:26:21 +02:00
René Kijewski
c1366e0fd8 Re-add {% set %} as alias for {% let %}
Commit [615fb82] introduced a regression. `{% set %}` and `{% let %}`
should be interchangeable, but only the latter syntax works.

This PR fixes the problem, and adds a regression test.

[615fb82]: <615fb82c65>
2024-05-18 09:14:23 +02:00
René Kijewski
38a2a86e55 Better error messages for truncated files 2024-05-17 18:29:47 +02:00
René Kijewski
615fb82c65 Speed-up node selection 2024-05-16 18:30:33 +02:00
René Kijewski
4fd4fb4d00 Add simple parser benchmark 2024-05-16 18:30:33 +02:00
René Kijewski
2b4f264d5a Better error message for break/continue 2024-05-16 13:50:49 +02:00
René Kijewski
e605478076 Better error message for {% macro super %} 2024-05-16 13:50:49 +02:00
René Kijewski
b668774f9b Fix parsing nested comments
This changes makes parsing nested comments run in linear time, and
constant space.
2024-05-01 13:52:46 +02:00
Guillaume Gomez
cbd74ad520 Fix clippy lint 2024-04-26 16:50:12 +02:00
Guillaume Gomez
c6d0ba8dbc Add checks for chars 2024-04-26 16:50:12 +02:00
Guillaume Gomez
3e5ccaeea5 Add more tests for floating parsing 2024-04-24 14:46:43 +02:00
vallentin
c1d945a882 Moved cfg not windows 2024-04-21 14:35:21 +02:00
Guillaume Gomez
ad73f755e9 Correctly handle whitespace character(s) on filter blocks 2024-04-12 17:23:42 +02:00
Guillaume Gomez
0b4b7d6345 Improve error message by providing the file where the error occurred if it is not an inlined source 2024-04-05 12:13:54 +02:00
Guillaume Gomez
5338f62a93 Add support for filter chaining in filter blocks 2024-03-11 14:25:46 +01:00
Guillaume Gomez
9439638e0f Create new Filter type 2024-03-11 14:25:46 +01:00
René Kijewski
7aa4a80791 Remove redundant import 2024-03-07 17:10:58 +01:00
Guillaume Gomez
279105bd4d Remove unused Next variant value 2024-03-07 14:55:53 +01:00
Guillaume Gomez
dab6c8007c Add support for filter block 2024-03-07 11:33:34 +01:00
Guillaume Gomez
29687db996 Improve error when whitespace control is used on extends 2024-01-22 17:13:01 +01:00
Dirkjan Ochtman
eb4c4ec915 Bump version numbers for release 2024-01-18 11:30:54 +01:00
Dirkjan Ochtman
79738ff238 Fix support for mixed case variables 2024-01-18 11:23:18 +01:00
Dirkjan Ochtman
250828a6d2 Yield error on deep AST recursion 2024-01-18 07:39:25 +01:00
max
2c7759c0d0 Improve performance of find_used_templates
Signed-off-by: max <gmx.sht@gmail.com>
2024-01-17 17:58:53 +01:00
Fabio Valentini
b1386c1fbf parser: add missing license files 2024-01-15 07:28:38 +01:00
Dirkjan Ochtman
84c2094e87 parser: add test for target recursion overflow 2024-01-11 16:32:50 +01:00
Dirkjan Ochtman
10c38c51f6 parser: limit target recursion 2024-01-11 16:32:50 +01:00