319 Commits

Author SHA1 Message Date
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
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