40 Commits

Author SHA1 Message Date
René Kijewski
d531c96d13 parser: recognize/reject prefixed ids and lits in macro calls 2025-06-05 18:44:02 +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
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
René Kijewski
eaccbb02ae Comparison operators cannot be chained 2025-05-23 01:26:19 +02:00
Guillaume Gomez
06c32d6d18 Allow super in calls 2025-05-22 23:04:52 +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
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
b402936db3 generator: add named arguments for filters 2025-04-21 23:11:24 +02: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
627d58bc3b parser: simplify ErrorContext construction 2024-05-21 11:26:21 +02:00
Guillaume Gomez
cbd74ad520 Fix clippy lint 2024-04-26 16:50:12 +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
Guillaume Gomez
dab6c8007c Add support for filter block 2024-03-07 11:33:34 +01:00
Dirkjan Ochtman
250828a6d2 Yield error on deep AST recursion 2024-01-18 07:39:25 +01:00
Guillaume Gomez
e4b8ca3c44 Allow trailing comma in macro definition and call 2023-12-07 11:03:26 +01:00
Guillaume Gomez
b3020ee8bf Allow to pass named arguments to macro calls 2023-11-28 11:36:09 +01:00
Andrew Dona-Couch
6cbfde0451 Derive Clone for Expr and Target 2023-11-13 20:24:02 +01:00
Guillaume Gomez
76462255ea Create a type alias for all IResult to simplify code reading 2023-10-25 16:26:36 +02:00
Guillaume Gomez
6dae920a45 Create ErrorContext type 2023-10-25 14:30:35 +02:00
Dirkjan Ochtman
36f4442978 Require Expr::parse() callers to supply Level 2023-09-28 17:28:26 +02:00
Dirkjan Ochtman
5718175291 Move Level into the crate root 2023-09-28 17:28:26 +02:00
Dirkjan Ochtman
c8530493a1 Limit expression nesting level to avoid stack overflows 2023-09-28 14:43:44 +02:00
Dirkjan Ochtman
2e8e42af45 Use char_indices() to get byte indices for characters 2023-09-11 12:19:16 +02:00
Dirkjan Ochtman
dd9635ace6 Rename some variables 2023-09-11 12:19:16 +02:00
René Kijewski
d4fbad1db2 Optimize parsing boolean literals, too 2023-08-03 00:02:04 +02:00
René Kijewski
95ff27c087 Parse paths and identifiers only once
In the old implementation each variable in an expression would be parsed
up to three times:

* Try to parse a path because it contains a leading double colon, or
  infix double colons.
* Try to parse it as path again by scanning for an identifier that
  contains an upper case character.
* Fall back to scanning for any identifier.

This PR turns all three steps into one, without the need for
backtracking.
2023-08-03 00:02:04 +02:00
René Kijewski
50745e41c2 parser: don't truncates whitespaces after arrays 2023-08-02 11:09:05 +02:00
René Kijewski
985eb8955f Fix parsing arrays
This change

* allows using empty arrays `[]` in expessions,
* adds a cut when the leading `[` was encountered, and
* fixes the interaction between arrays and boolean OR.

IMO the restriction that you couldn't use empty arrays is not needed.
The missing cut made error messages slictly worse if you forget to add
the closing `]`.

Filter expressions must not have white spaces before the pipe `|`. The
white space is used to tell a filter expressions, and `std::ops::Or`
apart.
2023-07-31 21:29:35 +02:00
René Kijewski
107bdfdd76 Fix parsing calls
This change:

* adds a cut when the leading `(` was encountered, and
* fixed the interaction between call expressions and boolean OR.
2023-07-31 21:29:35 +02:00
Dirkjan Ochtman
447aab0f10 parser: move Expr parser helpers into callers 2023-07-31 10:27:15 +02:00
Dirkjan Ochtman
40239f0f20 parser: move single expr parsers into Expr impl 2023-07-31 10:27:15 +02:00
Dirkjan Ochtman
ea1b4f9c41 parser: move binary operator parsers into Expr impl 2023-07-31 10:27:15 +02:00
Dirkjan Ochtman
8d8391543c parser: flatten top-level Expr interface 2023-07-31 10:27:15 +02:00
Dirkjan Ochtman
c5174eb829 parser: move suffix parsers into impl block 2023-07-31 10:27:15 +02:00
Dirkjan Ochtman
2376cc6815 parser: move nested_parenthesis() helper into node module 2023-07-31 10:27:15 +02:00
Dirkjan Ochtman
e40e93796f Extract askama_parser crate 2023-07-31 10:27:15 +02:00