Skip to content

feat!: use jinja for templating#13

Open
seblyng wants to merge 15 commits into
ropez:masterfrom
seblyng:jinja
Open

feat!: use jinja for templating#13
seblyng wants to merge 15 commits into
ropez:masterfrom
seblyng:jinja

Conversation

@seblyng
Copy link
Copy Markdown
Contributor

@seblyng seblyng commented Mar 17, 2026

AI-assisted🤖

Seems to work but I want to look through the code myself as well.
Should also decide if we want to do this since it will be a breaking change.

I am perfectly fine with this since it is probably only us who are using this. We can also just implement something super simple or just ask AI to convert all the old potential http files to use the new syntax. I would expect that to be very easy

seblyng added 3 commits March 17, 2026 18:39
Swap out our own implementation of substitution with something a lot
more powerful like jinja
Comment thread src/ui/output.rs
Empty,
Preview(String),
Request(HttpRequestInfo),
Request(Box<HttpRequestInfo>),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a clippy lint if you wondered

1. clippy: large size difference between variants
   for further information visit https://rust-lang.github.io/rust-clippy/rust-1.91.0/index.html#large_enum_variant
   `#[warn(clippy::large_enum_variant)]` on by default [large_enum_variant]
   output.rs:61:5: the largest variant contains at least 328 bytes
   output.rs:60:5: the second-largest variant contains at least 24 bytes
   output.rs:61:13: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum: `Box<HttpRequestInfo>`

seblyng added 7 commits March 17, 2026 21:34
Only place where it is used, so belong more in there than in
substitute.rs
We are never setting fallback to anything other than `None`, so the code
was essentially dead. Remove it. Jinja handles fallback itself
Need a way to define if we are selecting one or multiple values from a list.
We can add custom filters to jinja!
Avoid inlining method just for the sake of it. Make diff a bit smaller
and easier to look at
@seblyng seblyng marked this pull request as ready for review March 17, 2026 22:02
Comment thread example/create_issue.http
"title": "Found a bug",
"body": "I'm having a problem with this.",
"labels": [ {{ label[, ]["] }} ],
"labels": ["{{ label | select_multiple | join('", "') }}"],
Copy link
Copy Markdown
Contributor Author

@seblyng seblyng Mar 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now have something very powerful like jinja (if we merge this), and we can potentially avoid some hardcoded restrictions we have. For example, we have a requirement now for a list to be like this:

[[label]]
name = "foo"
value = "foo"

[[label]]
name = "bar"
value = "bar"

So name and value keys.

I propose that we at least keep it like this for this PR to make the scope a bit smaller, and then potentially do another breaking change if we want.

We can avoid to "map" it internally (like we do in for example the list_option_to_string and other places) and instead just do it like this in the template:

["{{ label | select_multiple | map(attribute="value") | join('", "') }}"]

I haven't thought about potential pitfalls with this though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant