aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive/src/generator.rs (unfollow)
Commit message (Collapse)AuthorFilesLines
2024-01-24Add poem integrationHEADmainLibravatar cel 🌸1-0/+16
2024-01-17Allow included templates to `extend`, `import`, and `macro`Libravatar max1-21/+29
Signed-off-by: max <gmx.sht@gmail.com>
2024-01-12Generator: make `normalize_identifier` faster (#946)Libravatar René Kijewski1-54/+105
`normalize_identifier` is called quite often in the generator, once for every variable name or path element that is written. This PR aims to speed up the function by * using a per-length input string length replacement map * binary searching the replacement map instead of a linear search Diffent, but functionally equivalent implementations were compared: ```text * linear search in one big map: 348.44 µs * binary search in one big map: 334.46 µs * linear search in a per-length map: 178.84 µs * binary search in a per-length map: 154.54 µs * perfect hashing: 170.87 µs ``` The winner of this competition is "binary search in a per-length map". It does not introduce new dependencies, but has the slight disadvantage that it uses one instance of `unsafe` code. I deem this disadvantage acceptable, though. Nb. It was also tested if a variant that only stores the replaced string would be faster. This "optimization" proved to be slower for all implementations except "binary search in a per-length map", for which it has the same runtime. Without a clear advantage to use the "optimized version", I chose to use the more easy to read slice of tuples variant. Obviously, for all measurements: YMMV.
2024-01-12Add `as_ref` builtin filterLibravatar Guillaume Gomez1-0/+17
2024-01-10Revert "Add automatic borrowing to let statement"Libravatar Guillaume Gomez1-7/+0
This reverts commit 3d52283b74573af509deb3c47cbabf7b7b58b1dd.
2024-01-09Make the `markdown` filter compatible with `String`Libravatar Jakub Stachurski1-1/+1
This commit solves issue #719. This is done by making the markdown filter borrow the string and simplifying the filter to accept `&str` instead of `AsRef<str>` Add test for the markdown filter using as input Revert markdown filter changes Revert unnecessary changes Improve test_markdown_owned_string test Use cargo fmt
2023-12-13Add automatic borrowing to let statementLibravatar max1-0/+7
Signed-off-by: max <gmx.sht@gmail.com>
2023-12-13Bugfix in `is_attr_self()`Libravatar max1-1/+1
Signed-off-by: max <gmx.sht@gmail.com>
2023-11-28Allow to pass named arguments to macro callsLibravatar Guillaume Gomez1-1/+55
2023-11-22Enhance match to include multiple targets (#911)Libravatar PizzasBear1-0/+10
Signed-off-by: max <gmx.sht@gmail.com>
2023-11-20Improve macro call arguments loopLibravatar Guillaume Gomez1-4/+1
2023-11-20Improve output error for non-matching number of arguments for macrosLibravatar Guillaume Gomez1-1/+8
2023-11-01Remove unused `_did_loop` condition if `else` block is emptyLibravatar Guillaume Gomez1-9/+21
2023-11-01Avoid passing around duplicate dataLibravatar Dirkjan Ochtman1-13/+2
2023-11-01Cleanup imports a bitLibravatar Dirkjan Ochtman1-4/+4
2023-11-01Implement Default for MapChainLibravatar Dirkjan Ochtman1-7/+9
2023-11-01Move build_template() up to the crate rootLibravatar Dirkjan Ochtman1-61/+8
2023-11-01Remove unnecessary type annotationLibravatar Dirkjan Ochtman1-1/+1
2023-11-01Attach find_used_templates() to TemplateInputLibravatar Dirkjan Ochtman1-42/+1
2023-11-01Move TemplateArgs into input moduleLibravatar Dirkjan Ochtman1-129/+2
2023-11-01Inline nested derive_template() implementationLibravatar Dirkjan Ochtman1-11/+1
2023-10-12Allow macros to take `self` as an argumentLibravatar PizzasBear1-1/+1
2023-08-01parser: import `parser::{Expr, Node}`Libravatar René Kijewski1-3/+2
2023-08-01parser: add type for `Node::Comment`Libravatar René Kijewski1-5/+5
2023-08-01parser: remove re-exports `parser::{node,expr}::*`Libravatar René Kijewski1-3/+5
2023-08-01parser: add type for `Node::Extends`Libravatar René Kijewski1-1/+1
2023-08-01parser: add type for `Node::Include`Libravatar René Kijewski1-8/+7
2023-08-01parser: rename `Node::Cond` into `If` and add typeLibravatar René Kijewski1-8/+7
2023-08-01parser: add type for `Node::Let`Libravatar René Kijewski1-31/+19
2023-08-01parser: add type for `Node::Raw`Libravatar René Kijewski1-4/+4
2023-08-01parser: add type for `Node::Lit`Libravatar René Kijewski1-6/+7
2023-08-01parser: add type for `Node::BlockDef`Libravatar René Kijewski1-14/+6
2023-08-01parser: add type for `Node::Match`Libravatar René Kijewski1-7/+11
2023-08-01parser: add type for `Node::Call`Libravatar René Kijewski1-7/+10
2023-08-01parser: add type for `Node::Import`Libravatar René Kijewski1-4/+4
2023-08-01parser: let `Macro` know its nameLibravatar René Kijewski1-1/+1
2023-07-31parser: rename block to nodesLibravatar Dirkjan Ochtman1-3/+3
2023-07-31parser: define a struct for MatchLibravatar Dirkjan Ochtman1-4/+3
2023-07-31parser: define a struct for CondLibravatar Dirkjan Ochtman1-4/+4
2023-07-31Extract askama_parser crateLibravatar Dirkjan Ochtman1-1/+1
2023-07-31derive: move Parsed into parser moduleLibravatar Dirkjan Ochtman1-36/+1
2023-07-31derive: move generator-specific methods out of ExprLibravatar Dirkjan Ochtman1-2/+71
2023-07-31derive: define separate ParseError typeLibravatar Dirkjan Ochtman1-1/+5
2023-07-31derive: move Syntax into parser moduleLibravatar Dirkjan Ochtman1-2/+1
2023-07-24Fix Rust macro invocations not accepting a path (#837)Libravatar Matthew Taylor1-3/+3
2023-06-28Cache include AST to reduce parsing overheadLibravatar Dirkjan Ochtman1-23/+16
2023-06-28Inline child() method to avoid borrowing all fieldsLibravatar Dirkjan Ochtman1-27/+23
2023-06-28Avoid reparsing included templates if possibleLibravatar Dirkjan Ochtman1-4/+23
2023-06-28Parse templates onceLibravatar Dirkjan Ochtman1-13/+44
2023-05-19Update to rocket 0.5-rc.3Libravatar Vypo Mouse1-6/+15