Updates rkt_dyn_templates to tera2 - #22
Draft
martynp wants to merge 1 commit into
Draft
Conversation
Move Tera v1 support to `tera1` feature flag and fix autoescape handling bug. AI-Tool: Claude Code
There was a problem hiding this comment.
Pull request overview
Updates rkt_dyn_templates to Tera 2 while retaining Tera 1 compatibility.
Changes:
- Adds separate
teraandtera1feature paths. - Revises autoescaping and adds coverage for HTML, HTM, XML, and raw templates.
- Tests both Tera versions and updates example dependencies.
Reviewed changes
Copilot reviewed 11 out of 14 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
contrib/dyn_templates/Cargo.toml |
Defines Tera version features and dependencies. |
contrib/dyn_templates/src/lib.rs |
Documents and reexports selected Tera version. |
contrib/dyn_templates/src/engine/mod.rs |
Integrates both Tera feature paths. |
contrib/dyn_templates/src/engine/tera.rs |
Adapts initialization, escaping, and rendering. |
contrib/dyn_templates/tests/templates.rs |
Adds version-specific autoescape tests. |
contrib/dyn_templates/tests/templates/tera/htm_test.htm.tera |
Adds HTM escaping fixture. |
contrib/dyn_templates/tests/templates/tera/xml_test.xml.tera |
Adds XML escaping fixture. |
scripts/test.sh |
Tests Tera 1 and Tera 2 separately. |
examples/todo/Cargo.toml |
Updates rand requirement. |
examples/pastebin/Cargo.toml |
Updates rand requirement. |
examples/chat/Cargo.toml |
Updates rand requirement. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| use tera::{Context, Tera}; | ||
|
|
||
| // Enabling both `tera1` and `tera` is not an error, because Cargo features | ||
| // have to stay additive. If both are enabled `tera`` has priority. |
Comment on lines
+277
to
+278
| /// extension-free name, so this is decided by their path alone: if Tera | ||
| /// ever stops preferring the path over the name, these all fail. |
| AUTOESCAPE_SUFFIXES | ||
| .iter() | ||
| .any(|s| path.ends_with(s)) | ||
| .then(|| Cow::Owned(name.to_owned())) |
Comment on lines
46
to
+48
| /// avoid version mismatches. For instance, when registering a Tera filter, the | ||
| /// [`tera::Value`] and [`tera::Result`] types are required. Import them from | ||
| /// `rkt_dyn_templates::tera`. The example below illustrates this: | ||
| /// [`tera::Value`] and result types are required. Import them from | ||
| /// `rkt_dyn_templates::tera`. The example below illustrates this. |
Comment on lines
+19
to
+21
| # `tera1` selects the deprecated Tera 1.x; `tera` selects Tera 2.x. Enabling | ||
| # both is not an error -- Cargo features must stay additive -- but `tera` | ||
| # takes precedence and Tera 1.x goes unused. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Move Tera v1 support to
tera1feature flag and fix autoescape handling bug.AI-Tool: Claude Code