303 Commits

Author SHA1 Message Date
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
max
5cad82f38e Allow included templates to extend, import, and macro
Signed-off-by: max <gmx.sht@gmail.com>
2024-01-17 17:58:53 +01:00
René Kijewski
3cddb91889
Generator: make normalize_identifier faster (#946)
`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-12 20:41:46 +01:00
Guillaume Gomez
12e178ce40 Add test for as_ref builtin filter 2024-01-12 10:38:15 +01:00
Guillaume Gomez
1ee067f2b6 Revert "Add automatic borrowing to let statement"
This reverts commit 3d52283b74573af509deb3c47cbabf7b7b58b1dd.
2024-01-10 10:42:31 +01:00
Jakub Stachurski
50c64bc865 Make the markdown filter compatible with String
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
2024-01-09 21:23:47 +01:00
max
3d52283b74 Add automatic borrowing to let statement
Signed-off-by: max <gmx.sht@gmail.com>
2023-12-13 16:47:02 +01:00
max
28182a1549 Bugfix in is_attr_self()
Signed-off-by: max <gmx.sht@gmail.com>
2023-12-13 16:47:02 +01:00
Guillaume Gomez
e4b8ca3c44 Allow trailing comma in macro definition and call 2023-12-07 11:03:26 +01:00
Guillaume Gomez
b5797cba88 Add macro test with only argument being passed as named 2023-12-07 09:10:32 +01:00
dependabot[bot]
736480c38b build(deps): update comrak requirement from 0.18 to 0.20
Updates the requirements on [comrak](https://github.com/kivikakk/comrak) to permit the latest version.
- [Release notes](https://github.com/kivikakk/comrak/releases)
- [Changelog](https://github.com/kivikakk/comrak/blob/main/changelog.txt)
- [Commits](https://github.com/kivikakk/comrak/compare/0.18.0...0.20.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-30 13:55:46 +01:00
Dirkjan Ochtman
69e2db6efa Upgrade to comrak 0.19 2023-11-30 13:33:06 +01:00
Guillaume Gomez
28e26751ce Add tests for named arguments in macro calls 2023-11-28 11:36:09 +01:00
PizzasBear
696561003d
Add better support for rust-like number literals (#908)
Signed-off-by: max <gmx.sht@gmail.com>
2023-11-22 16:09:33 +01:00
PizzasBear
48c6cd327d
Enhance match to include multiple targets (#911)
Signed-off-by: max <gmx.sht@gmail.com>
2023-11-22 14:56:14 +01:00
Guillaume Gomez
ea7267dfc2 Add UI tests for macros error message 2023-11-20 10:34:26 +01:00
Guillaume Gomez
77d5d28b20 Add UI test for elif error message 2023-10-25 14:54:14 +02:00
Guillaume Gomez
c056d6287b Improve error for invalid name used in endmacro 2023-10-25 14:30:35 +02:00
Guillaume Gomez
c3281e353d Improve error for invalid name used in endblock 2023-10-25 14:30:35 +02:00
Guillaume Gomez
a7f5186bf4 Add test specifically for named blocks, and named macros 2023-10-23 15:13:27 +02:00
max
5ee2dfbe6b Add test for macro self argument
Signed-off-by: max <gmx.sht@gmail.com>
2023-10-12 13:57:48 +02:00
Dirkjan Ochtman
daa8d89b57 Add MSRV checking in CI
Bump MSRV to 1.65 for the use of let .. else.
2023-09-29 16:13:24 +02:00
René Kijewski
eef38cea67 Pass Node parsing level to expressions 2023-09-28 17:28:26 +02:00
René Kijewski
238e4bbad7 Limit nesting in parser nodes, too 2023-09-28 17:28:26 +02:00
René Kijewski
985eb8955f Fix parsing arrays
This change

* allows using empty arrays `[]` in expessions,
* adds a cut when the leading `[` was encountered, and
* fixes the interaction between arrays and boolean OR.

IMO the restriction that you couldn't use empty arrays is not needed.
The missing cut made error messages slictly worse if you forget to add
the closing `]`.

Filter expressions must not have white spaces before the pipe `|`. The
white space is used to tell a filter expressions, and `std::ops::Or`
apart.
2023-07-31 21:29:35 +02:00
René Kijewski
107bdfdd76 Fix parsing calls
This change:

* adds a cut when the leading `(` was encountered, and
* fixed the interaction between call expressions and boolean OR.
2023-07-31 21:29:35 +02:00
Matthew Taylor
ac8de6260e
Fix Rust macro invocations not accepting a path (#837) 2023-07-24 11:39:14 +02:00
mataha
cba1fb8e50 Allow macros to be defined and called without arguments
This commit introduces a shorthand for defining and calling macros when
using them as a reusable substitute for variables assigned complex values
(e.g. string literals with or without newline escapes). The use-case is
formatting - from my experience it's easier to visually parse a `macro`
`endmacro` block than a multiline variable assignment.

Signed-off-by: mataha <mataha@users.noreply.github.com>
2023-06-12 10:35:40 +02:00
dependabot[bot]
a3ff30a5ea Update criterion requirement from 0.4 to 0.5
Updates the requirements on [criterion](https://github.com/bheisler/criterion.rs) to permit the latest version.
- [Changelog](https://github.com/bheisler/criterion.rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bheisler/criterion.rs/compare/0.4.0...0.5.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-24 09:47:44 +02:00
Dirkjan Ochtman
239f59b9b1 Upgrade to comrak 0.18 2023-05-20 08:17:35 +02:00
Dirkjan Ochtman
5ff1926702 Update comrak to 0.17 2023-03-28 10:11:34 +02:00
Guillaume Gomez
40be079d5d Add tests for whitespace argument in template derive proc-macro 2023-03-13 14:41:05 +01:00
Guillaume Gomez
4233b3114f Update tests for whitespace characters handling 2023-03-09 13:35:00 +01:00
Andrew Dona-Couch -- GitHub drop ICE
dc864486ec
Propogate size_hint from sub-blocks (#788)
Closes #786
2023-03-06 22:18:45 +01:00
Dirkjan Ochtman
417cb924ae
Bump versions for Askama 0.12 (#784) 2023-03-03 18:50:56 +01:00
René Kijewski
c131154cb1 Update comrak dependency to 0.16 2023-01-30 14:37:56 +01:00
Dirkjan Ochtman
3003d86264
Apply clippy suggestions for 1.67 (#769) 2023-01-30 09:51:23 +01:00
René Kijewski
23326b4765 Update ui test for trybuild 1.0.76
In <https://github.com/dtolnay/trybuild/pull/219> the output of error
messages was subtly changed, because they introduced a subdirectoy in
their temp path.

This PR fixes the mismatch between the expected and the actual output.
2023-01-24 09:55:54 +01:00
dependabot[bot]
4d0b7a4bf1 Update comrak requirement from 0.14 to 0.15
Updates the requirements on [comrak](https://github.com/kivikakk/comrak) to permit the latest version.
- [Release notes](https://github.com/kivikakk/comrak/releases)
- [Changelog](https://github.com/kivikakk/comrak/blob/main/changelog.txt)
- [Commits](https://github.com/kivikakk/comrak/compare/0.14.0...0.15.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-15 06:48:54 +01:00
Dirkjan Ochtman
6f52d0eef5 chore: remove allow(clippy::disallowed_names) 2022-11-07 11:14:43 +01:00
Dirkjan Ochtman
ee4dbf0d8d chore: apply clippy suggestions for 1.65 2022-11-07 11:14:43 +01:00
Allan Zhang
1b18bab91b Version bump in README and book
I was going through the book when I saw the version was still 0.8.

This commit ensures all references to Askama version are to 0.11.2.
Most of them already were.

Merge whenever appropriate for release, #722 related
2022-10-21 13:24:39 +02:00
dependabot[bot]
f88403430b
Update criterion requirement from 0.3 to 0.4 (#721)
Updates the requirements on [criterion](https://github.com/bheisler/criterion.rs) to permit the latest version.
- [Release notes](https://github.com/bheisler/criterion.rs/releases)
- [Changelog](https://github.com/bheisler/criterion.rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bheisler/criterion.rs/compare/0.3.0...0.4.0)

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

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-26 15:46:12 +02:00
René Kijewski
16a37f4097 Remove support for deprecated _parent field
The support for the magic `_parent` field is deprecated since v0.8.0
or issue #180. It's bothersome to keep this feature alive, when no-one
should be using it for 3 years.
2022-07-25 11:41:04 +02:00
René Kijewski
27447c8db1 Update to comrak v0.14 2022-07-20 15:25:17 +02:00
dependabot[bot]
ecf671945a Update comrak requirement from 0.12 to 0.13
Updates the requirements on [comrak](https://github.com/kivikakk/comrak) to permit the latest version.
- [Release notes](https://github.com/kivikakk/comrak/releases)
- [Changelog](https://github.com/kivikakk/comrak/blob/main/changelog.txt)
- [Commits](https://github.com/kivikakk/comrak/compare/0.12.0...0.13.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-07 08:08:48 +02:00
Bastien Orivel
ea66be1925 Allow {% endmacro name %}
Just migrated a repo from tera to askama and this was one of the only
things that was different. This is also coherent with `{% block %}` for
which I added the same feature years ago.
2022-04-29 13:35:20 +02:00
Guillaume Gomez
07cee10876 Add test for "minimize" config 2022-04-26 10:15:34 +02:00