1588 Commits

Author SHA1 Message Date
Guillaume Gomez
e7f2979b73 Add regression test for moving variables in let statement 2024-07-02 22:40:09 +02:00
Guillaume Gomez
fa467172dd Prevent jinja let to move variables 2024-07-02 22:39:28 +02:00
René Kijewski
145127e241
Merge pull request #40 from GuillaumeGomez/rename-as_ref
Rename `as_ref` filter into `ref`
2024-07-02 15:49:17 +02:00
René Kijewski
ca85ef6050
Merge pull request #37 from GuillaumeGomez/method-call
Favor methods over closure fields
2024-07-02 15:45:41 +02:00
Guillaume Gomez
d0bcba7d1c Update book for methods calls 2024-07-02 13:44:27 +02:00
Guillaume Gomez
6c46e4f7b8 Update tests about methods use 2024-07-02 13:44:27 +02:00
Guillaume Gomez
f2dcd1737e Favor methods over closure fields 2024-07-02 12:14:20 +02:00
René Kijewski
79e747a28a
Merge pull request #39 from GuillaumeGomez/ref-deref-ops
Allow to use `*` and `&` in expressions
2024-07-02 02:03:25 +02:00
René Kijewski
223470eb20
Merge pull request #38 from GuillaumeGomez/prevent-macro-move-var
Prevent jinja macros to move variables
2024-07-02 02:01:39 +02:00
Guillaume Gomez
daac80ff60 Update book to mention * and & operators 2024-07-01 21:11:41 +02:00
Guillaume Gomez
e5a3e1c763 Add regression test for * and & in expressions 2024-07-01 21:11:41 +02:00
Guillaume Gomez
b37e7d3703 Rename as_ref filter into ref 2024-07-01 21:09:18 +02:00
Guillaume Gomez
e9fc4a6db3 Allow to use * and & in expressions 2024-07-01 20:54:13 +02:00
Guillaume Gomez
62bbece0aa Add regression test to prevent moving variables 2024-07-01 18:05:16 +02:00
Guillaume Gomez
6be20d5782 Prevent jinja macros to move variables 2024-07-01 18:05:12 +02:00
Guillaume Gomez
eb419049bf
Merge pull request #36 from Kijewski/rest-pattern-struct#2
Add support for `..` in let pattern matching for structs (alternative take)
2024-06-29 00:02:08 +02:00
René Kijewski
f4ccdb6585 Better information that .. must come last in a named struct 2024-06-28 23:32:13 +02:00
René Kijewski
0d8373e3b2 Linted 2024-06-28 23:06:21 +02:00
René Kijewski
cf4f514d7e Move passing tests 2024-06-28 23:03:22 +02:00
René Kijewski
e84e1a6af2 Move Target into its own file 2024-06-28 22:56:34 +02:00
René Kijewski
6b8b97672a Better error message on missing comma 2024-06-28 22:48:45 +02:00
Guillaume Gomez
6ee3765098 Add regression test for .. pattern in structs 2024-06-28 05:25:21 +02:00
René Kijewski
e94525f483 Add support for .. in let pattern matching for structs 2024-06-28 05:25:21 +02:00
René Kijewski
214c4450b4
Merge pull request #32 from Kijewski/pr-uglier-json
Make JSON prettifying optional
2024-06-27 14:29:39 +02:00
René Kijewski
dcabf0cf1a feature: serde-json → serde_json 2024-06-27 14:25:22 +02:00
René Kijewski
64a8094aaf Split pretty and ugly JSON filter impl 2024-06-27 14:25:22 +02:00
René Kijewski
fd70667998
Merge pull request #34 from GuillaumeGomez/fix-links
Fix links in the book
2024-06-27 14:20:32 +02:00
Guillaume Gomez
5787781b78 Fix links in the book 2024-06-25 17:15:35 +02:00
René Kijewski
f7710a94d6 Add "json: too many args" ui test 2024-06-25 00:42:28 +02:00
René Kijewski
462c04c0a0 Make JSON prettifying optional
This PR adds an optional argument to the `|tojson` filter, which
controls if the serialized JSON data gets prettified or not. The
arguments works the same as flask's [`|tojson`][flask] filter, which
passes the argument to python's [`json.dumps()`][python]:

* Omitting the argument, providing a negative integer, or `None`, then
  compact JSON data is generated.
* Providing a non-negative integer, then this amount of ASCII spaces is
  used to indent the data. (Capped to 16 characters.)
* Providing a string, then this string is used as prefix. I attempts are
  made to ensure that the prefix actually consists of whitespaces,
  because chances are, that if you provide e.g. `&nsbp;`, then you are
  doing it intentionally.

This is a breaking change, because it changes the default behavior to
not prettify the data. This is done intentionally, because this is how
it works in flask.

[flask]: https://jinja.palletsprojects.com/en/3.1.x/templates/#jinja-filters.tojson
[python]: https://docs.python.org/3/library/json.html#json.dump
2024-06-25 00:12:25 +02:00
René Kijewski
78878f08b6
Merge pull request #31 from GuillaumeGomez/improve-level-api
Improve Level API a bit
2024-06-25 00:05:42 +02:00
Guillaume Gomez
fd1108c4bc
Merge pull request #18 from Kijewski/pr-iso646
Use ISO 646 alternative operators for bit ops + proper error messages for spaces around the `|filter` operator
2024-06-24 14:04:53 +02:00
Guillaume Gomez
4b847a27b2 Improve Level API a bit 2024-06-24 11:07:54 +02:00
René Kijewski
3459616be1 Update documentation 2024-06-23 21:09:07 +02:00
René Kijewski
bd36c4b7bd
Merge pull request #29 from GuillaumeGomez/improve-ui-error
Improve error message in case too much nesting
2024-06-23 20:59:10 +02:00
Guillaume Gomez
1f1cff059d Update ui tests 2024-06-23 20:55:23 +02:00
Guillaume Gomez
ae1e188118 Improve error message in case too much nesting 2024-06-23 20:55:23 +02:00
René Kijewski
50ac555684 Remove helper functions 2024-06-23 20:55:00 +02:00
René Kijewski
fb4d8a6073 Better error message for space + filter 2024-06-23 20:54:28 +02:00
René Kijewski
879d889bb2 Use ISO 646 alternative operators for bit ops
This change allows simplifying the use of filter expressions, because
you won't have to care about spaces around the `|` pipe operator.
2024-06-23 20:47:27 +02:00
Guillaume Gomez
704c506770
Merge pull request #27 from manunio/fix-filter-recursion-error
Update recursion ui error
2024-06-23 17:49:58 +02:00
manunio
4dee4e747f Update recursion ui error
I think previous input for filter-recursion ui test was not right as it
was not triggering error for recursion itself, for example:

```rust
fn fuzzed_filter_recursion() {
    const TEMPLATE: &str = include_str!("../tests/filter-recursion.txt");
    if let Err(e) = Ast::from_str(TEMPLATE, None, &Syntax::default()) {
        panic!("{e}");
    }
}
```

```sh
---- tests::fuzzed_filter_recursion stdout ----
thread 'tests::fuzzed_filter_recursion' panicked at rinja_parser/src/tests.rs:1121:9:
failed to parse template source at row 1, column 255 near:
"|A|AA|A|A|A|A|AA|A|A|A|A|AA|A|A|A|A|AA|A"...
```
2024-06-23 20:24:24 +05:30
René Kijewski
4e88a308c2
Merge pull request #24 from GuillaumeGomez/simplify-kws
Remove duplicated code to detect Rust keywords/identifiers
2024-06-23 15:06:28 +02:00
Guillaume Gomez
d4306a7afb
Merge pull request #26 from Kijewski/pr-more-derive-bench
derive: add librustdoc benchmarks
2024-06-22 17:52:29 +02:00
René Kijewski
e2e79ea4d6 Fix clippy warnings 2024-06-22 17:05:35 +02:00
René Kijewski
f54a985d41 derive: use macro to dedup code 2024-06-22 16:58:18 +02:00
René Kijewski
22811a7c86 derive: add librustdoc benchmarks 2024-06-22 16:46:22 +02:00
René Kijewski
cf2419b1a9 derive: bench in batches
Cloning a TokenStream is not for free. This change lets criterion do the
cloning outside of the measured time, and blackboxing is done by
criterion, too.

The benchmark runs ~10% faster, now.
2024-06-22 15:58:47 +02:00
Guillaume Gomez
62b891ffc3
Merge pull request #14 from Kijewski/pr-benchmark-derive
derive: add benchmark
2024-06-22 12:02:19 +02:00
René Kijewski
1ce549d260 derive: add benchmark
This PR adds the crate "rinja_derive_standalone", which is just like
"rinja_derive", though not a "proc_macro". This way we can easily expose
it's internals for testing and benchmarking.

Right now, the PR is more or less a prove of concept, and it probably
needs a handful more useful benchmark use cases to be worth the hassle.
2024-06-22 02:49:01 +02:00