350 Commits

Author SHA1 Message Date
Guillaume Gomez
e5a3e1c763 Add regression test for * and & in expressions 2024-07-01 21:11:41 +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
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
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
1f1cff059d Update ui tests 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
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
Guillaume Gomez
ddc75d6d84
Merge pull request #21 from Kijewski/pr-explicit-features
Only use explicit features
2024-06-20 20:00:48 +02:00
René Kijewski
bf93f4a755 serde-json is actually called serde_json 2024-06-20 19:03:04 +02:00
Guillaume Gomez
fc1d52d604 Add more tests for recursion errors 2024-06-20 18:53:14 +02:00
Guillaume Gomez
e2eb76b860 Fix block partial rendering 2024-06-17 18:33:34 +02:00
Guillaume Gomez
e7a8acf42e Fix formatting 2024-06-17 17:25:11 +02:00
Guillaume Gomez
870565eb8e Update ui tests 2024-06-17 17:18:55 +02:00
Guillaume Gomez
2d80cc3524 Rename everything to rinja 2024-06-17 15:58:52 +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
René Kijewski
38a2a86e55 Better error messages for truncated files 2024-05-17 18:29:47 +02:00
René Kijewski
a03a06c338 Add unclosed node ui tests 2024-05-17 18:29:47 +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
33f823d582 Add {% macro super %} test 2024-05-16 13:50:49 +02:00
Guillaume Gomez
4d237ab274 Fix new rustc lints 2024-05-16 13:47:02 +02:00
Guillaume Gomez
dd6b6be435 Fix wrong handling of nested templates with block 2024-05-16 13:47:02 +02:00
Guillaume Gomez
cefa443839 Remove "unused type" warnings in tests 2024-05-02 20:34:12 +02:00
Guillaume Gomez
ed512051cf Add deref builtin filter 2024-05-02 20:34:12 +02:00
René Kijewski
5955ba23c1 Remove obsolete trybuild outputs
The current main branch does not compile with rust 1.58 or earlier
anyway.
2024-04-29 08:33:32 +02:00
Guillaume Gomez
c6d0ba8dbc Add checks for chars 2024-04-26 16:50:12 +02:00
Guillaume Gomez
bd0bfaa95c Add test for block imports access 2024-04-25 11:09:02 +02:00
wrapperup
1347d36363 Add support for rendering a single block 2024-04-25 10:44:58 +02:00
Guillaume Gomez
3e5ccaeea5 Add more tests for floating parsing 2024-04-24 14:46:43 +02:00
René Kijewski
c48532fb17 Implement Render even if parsing failed
This makes error messages much more readable.
2024-04-18 12:54:15 +02:00
René Kijewski
c9a2254e58 Fix expected error message in UI test 2024-04-17 13:40:41 +02:00
Guillaume Gomez
ad73f755e9 Correctly handle whitespace character(s) on filter blocks 2024-04-12 17:23:42 +02:00
Andreas
8e067322fe Fix typo in regression test causing the wrong thing to be tested 2024-04-11 21:16:32 +02:00
Guillaume Gomez
7f6beca8a8 Add UI regression tests for cyclic dependencies 2024-04-11 20:39:29 +02:00
Guillaume Gomez
66b53eecaf Remove markdown filter and comrak dependency 2024-04-06 23:07:30 +02:00
Guillaume Gomez
45ae8daba4 Move cfg(not(windows)) at the top of tests/ui.rs 2024-04-05 12:13:54 +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
dependabot[bot]
19a01de03f build(deps): update comrak requirement from 0.21 to 0.22
Updates the requirements on comrak to permit the latest version.

---
updated-dependencies:
- dependency-name: comrak
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-01 13:34:05 +02:00
Guillaume Gomez
353304ca34 Fix tests warnings 2024-03-12 16:28:20 +01:00
Guillaume Gomez
ad97dc1d2a Add test for filter block chaining 2024-03-11 14:25:46 +01:00
René Kijewski
5149cd9307 Implement Template for &Template
`Template` does not have methods that alter `self` is any way, so a
reference to a `Template` can implement `Template`, too.
2024-03-07 16:35:56 +01:00
Guillaume Gomez
1810047b1e Add test for filter block 2024-03-07 11:33:34 +01:00
Dirkjan Ochtman
6cd72ec54c Bump versions for semver-incompatible release 2024-03-05 11:34:09 +01:00
dependabot[bot]
c2c9bd8170 build(deps): update comrak requirement from 0.20 to 0.21
Updates the requirements on comrak to permit the latest version.

---
updated-dependencies:
- dependency-name: comrak
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-26 09:38:45 +01:00
Guillaume Gomez
585a992246 Add ui test for extends error 2024-01-22 17:13:01 +01:00
Dirkjan Ochtman
79738ff238 Fix support for mixed case variables 2024-01-18 11:23:18 +01:00