411 Commits

Author SHA1 Message Date
Guillaume Gomez
b8404c7828 Add ui regression test for new escape filter error 2024-08-18 22:43:59 +02:00
Guillaume Gomez
71f49a8fc2 Add support for prefixes for string literals 2024-08-18 22:43:59 +02:00
Guillaume Gomez
1a24ace17b Add support for b prefix for char literals 2024-08-18 22:35:03 +02:00
Guillaume Gomez
7a7e415822 Add support for | operator in when 2024-08-15 21:10:29 +02:00
René Kijewski
90096ef973 ci: sort elements in Cargo.toml 2024-08-13 19:17:37 +02:00
Guillaume Gomez
d5fef24ff7
Merge pull request #119 from Kijewski/pr-no-when
parser: allow `match` nodes w/o `when` if there is an `else`
2024-08-13 17:48:15 +02:00
René Kijewski
ed91a909ab derive: better error messages for syntax testing 2024-08-13 17:39:57 +02:00
René Kijewski
e4c5ca3f6b parser: reject closing delims that look like an op 2024-08-13 16:56:33 +02:00
Guillaume Gomez
9873ea065f Improve compile-time if conditions handling 2024-08-09 20:32:38 +02:00
René Kijewski
f818c582bf parser: allow match nodes w/o when if there is an else 2024-08-08 22:28:14 +02:00
René Kijewski
5efd31310f parser: understand arbitrarily mixed up end nodes 2024-08-07 20:43:18 +02:00
René Kijewski
dec67c686b parser: tell user proper keyword to end node 2024-08-07 20:30:25 +02:00
René Kijewski
0628afaf5e parser: add wrong node terminator test 2024-08-07 20:28:33 +02:00
Guillaume Gomez
ebcfff66cc
Merge pull request #117 from Kijewski/pr-template-times-x
derive: allow split up template attributes
2024-08-07 14:38:33 +02:00
René Kijewski
f25dac9409 derive: allow split up template attributes
In generated code or macros, it might be useful to emit multiple
`#[template]` attributes. E.g.

```rust
 #[template(source = "Hello!")]
 #[template(ext = "txt")]
 struct Hello;
```
2024-08-07 07:09:19 +02:00
René Kijewski
ed692a087d derive: don't panic if the extension is non-UTF-8 2024-08-07 07:06:55 +02:00
René Kijewski
1ff32cb0ab derive: understand extension .rinja 2024-08-07 06:12:42 +02:00
René Kijewski
6fe504e133 Bump version numbers to v0.3.0 2024-08-01 15:41:37 +02:00
Guillaume Gomez
4de78ad9be Improve compilation error message for invalid usage of rest pattern 2024-07-31 19:28:50 +02:00
Guillaume Gomez
c860a22e85 Add test for rest pattern 2024-07-30 22:31:42 +02:00
René Kijewski
5e98580ae3 derive: highlight value, not key 2024-07-30 14:04:19 +02:00
René Kijewski
08674bde11 derive: without rendered message for now 2024-07-29 21:57:28 +02:00
René Kijewski
821a147b37 Doens't work: no indentation 2024-07-29 18:38:32 +02:00
René Kijewski
2e887a56a6 derive: use config span in error message 2024-07-29 16:50:39 +02:00
René Kijewski
c3639ec14a derive: use source/path as error source span 2024-07-29 15:48:18 +02:00
René Kijewski
fa8c936cff derive: way less noisy error messages 2024-07-29 13:46:31 +02:00
René Kijewski
380ecc1d8e derive: properly display error locations 2024-07-29 05:05:00 +02:00
Guillaume Gomez
e74f0d20ba Change the error message to make it start at the as keyword 2024-07-28 21:37:22 +02:00
René Kijewski
a6a474514e Implement operator as in template language
Because it is not always super obvious if an identifier refers to `T` or
`&T`, any references are automatically followed.
2024-07-28 18:02:14 +02:00
Guillaume Gomez
fcf1a97d9d Add tests for if (not) defined feature 2024-07-24 13:14:51 +02:00
René Kijewski
b593f1ffa7 parser: better error msg for unkn. number suffices 2024-07-20 12:15:13 +02:00
René Kijewski
5163e38355 filters: proper escaping for |linebreaks and friends
The filters `|linebreaks`, `|linebreaksbr` and `|paragraphbreaks`
generate HTML code to be embedded in a page. Having to specify that the
output of these filters is `|safe` is cumbersome. Also, these filters
need to operate on already escaped HTML data. This could be done by
writing `{{ s|escape|linebreaks|safe }}`.

This PR does the input and output formatting escaping for the user. The
input gets escaped for HTML (invariant of the selected escaper), and the
output gets marked as HTML safe.
2024-07-13 14:44:28 +02:00
René Kijewski
fba84762cf tests: remove stray print = "code" 2024-07-13 13:12:23 +02:00
René Kijewski
10e67fa312 Reimplement {% filter %} block
This PR reimplements the code generation for `{% filter %}` blocks, so
that the data is written directly into its destination writer, without
using a buffer. This way it behaves like a specialized
`{{ expr|filter1|filter2 }}` would, if the `expr` was a `Template` that
contained the body of the filter block.
2024-07-13 11:11:04 +02:00
René Kijewski
cd6b4ad49b
Merge pull request #76 from GuillaumeGomez/update-authors
Update authors list for `testing/Cargo.toml`
2024-07-13 10:48:08 +02:00
Guillaume Gomez
ee054c4f07 Update authors list for testing/Cargo.toml 2024-07-13 10:35:43 +02:00
Guillaume Gomez
b753dd6e4d Add more tests for filter block feature 2024-07-13 10:29:11 +02:00
René Kijewski
34073642b1 Run typos to fix typos 2024-07-12 07:07:00 +02:00
Sheldon Young
39e3c951f4
phf should be a dev dependency
The `phf` crate is used in a benchmark for testing identifier normalization but not in the library itself.  This moves it to be a dev dependency.
2024-07-11 12:13:56 -07:00
René Kijewski
85330b353a Raise the MSRV to 1.71 2024-07-10 21:38:43 +02:00
René Kijewski
277cff4ebf Reset all version numbers to 0.2.0 2024-07-09 12:48:41 +02:00
René Kijewski
1017451579 Speed-up HTML escaping by using equal sized entities
By using codepoint entities like `'&'` → `"&"`, we have a much
smaller lookup table (58 bytes instead of 29× pointer size ~= 232
bytes). This makes the cache happy, and the benchmark run about ~20%
faster.

```text
$ cargo bench --bench escape
Escaping                time:   [3.4087 µs 3.4126 µs 3.4168 µs]
                        change: [-19.790% -19.580% -19.354%] (p = 0.00 < 0.05)
                        Performance has improved.
```
2024-07-08 00:52:56 +02:00
René Kijewski
9beca5ed10 Add MsgValidEscapers to show list of configured escapers 2024-07-07 22:51:57 +02:00
René Kijewski
6b0ea27742 More useful error message and UI tests for missing escaper 2024-07-07 22:51:23 +02:00
René Kijewski
6a6994670d Show error reason when template could not be read 2024-07-04 11:02:58 +02:00
René Kijewski
ee3a9e675a Add .rustfmt.toml configuration
This PR configures the formatting with a few defaults that aid
readability, in my opinion. One drawback of adding this file is that
rustfmt uses unstable features, now, and you have to use nightly to run
it:

```sh
cargo +nightly fmt --all
```
2024-07-04 07:05:57 +02:00
Guillaume Gomez
37c300d483
Merge pull request #42 from GuillaumeGomez/top-level-nodes-errors
Generate better errors for top level nodes
2024-07-03 10:39:33 +02:00
René Kijewski
d4b363b9a4 Dedup top-level check in heritage 2024-07-03 01:18:36 +02:00
Guillaume Gomez
e7f2979b73 Add regression test for moving variables in let statement 2024-07-02 22:40:09 +02:00
Guillaume Gomez
27e12f083b Add UI tests for top level nodes 2024-07-02 22:15:02 +02:00