Skip to content

Updates rkt_dyn_templates to tera2 - #22

Draft
martynp wants to merge 1 commit into
mainfrom
add_support_for_tera2
Draft

Updates rkt_dyn_templates to tera2#22
martynp wants to merge 1 commit into
mainfrom
add_support_for_tera2

Conversation

@martynp

@martynp martynp commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Move Tera v1 support to tera1 feature flag and fix autoescape handling bug.

AI-Tool: Claude Code

Move Tera v1 support to `tera1` feature flag and fix autoescape handling
bug.

AI-Tool: Claude Code
@martynp
martynp requested a balanced review from Copilot August 31, 2026 20:50
@martynp
martynp marked this pull request as draft August 31, 2026 20:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates rkt_dyn_templates to Tera 2 while retaining Tera 1 compatibility.

Changes:

  • Adds separate tera and tera1 feature 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.
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.

2 participants