23 Commits

Author SHA1 Message Date
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
Guillaume Gomez
f2dcd1737e Favor methods over closure fields 2024-07-02 12:14:20 +02:00
Guillaume Gomez
b37e7d3703 Rename as_ref filter into ref 2024-07-01 21:09:18 +02:00
Guillaume Gomez
6be20d5782 Prevent jinja macros to move variables 2024-07-01 18:05:12 +02:00
René Kijewski
e84e1a6af2 Move Target into its own file 2024-06-28 22:56:34 +02:00
René Kijewski
e94525f483 Add support for .. in let pattern matching for structs 2024-06-28 05:25:21 +02:00
René Kijewski
64a8094aaf Split pretty and ugly JSON filter impl 2024-06-27 14:25:22 +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
d4e36fa59e Remove duplicated code to detect Rust keywords/identifiers 2024-06-20 23:16:52 +02:00
René Kijewski
bdc3c79e95 Test UTF-8-ness only in #[test]s 2024-06-20 22:02:39 +02:00
René Kijewski
bf93f4a755 serde-json is actually called serde_json 2024-06-20 19:03:04 +02:00
René Kijewski
ad645e7a21 Don't capture std::fmt::Error in rinja::Error
`std::fmt::Error` does not know why it failed, only that it failed, as
it has a single value. This PR removes the captured value, to make the
code a bit more dense.
2024-06-19 00:12:51 +02:00
René Kijewski
b15b61cb2a Generator: reduce amount of intermediate allocations
No need to allocate a String, just to write it into another String
afterwards. This PR replaces the usages for `format!()` with
`format_args!()`.
2024-06-18 17:22:31 +02:00
Guillaume Gomez
3657569276 Remove returned Result from Buffer::writeln 2024-06-18 11:20:01 +02:00
Guillaume Gomez
8e964b964e Remove useless indent information from Buffer 2024-06-17 18:44:59 +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
c49734d706 Fix clippy lints 2024-06-17 17:18:55 +02:00
Guillaume Gomez
32d2c6de27 Remove From trait implementations for CompileError 2024-06-17 17:18:55 +02:00
Guillaume Gomez
d6d1189cd5 Migrate errors with file information 2024-06-17 17:18:55 +02:00
Guillaume Gomez
bf3934257c Update to new WithSpan type in askama_derive 2024-06-17 17:18:55 +02:00
Guillaume Gomez
2d80cc3524 Rename everything to rinja 2024-06-17 15:58:52 +02:00