Skip to content

feat(allowlist): add Tera template support - #2157

Open
gomitrah wants to merge 1 commit into
alibaba:mainfrom
gomitrah:feat/allowlist-tera
Open

gomitrah wants to merge 1 commit into
alibaba:mainfrom
gomitrah:feat/allowlist-tera

Conversation

@gomitrah

@gomitrah gomitrah commented Dec 1, 2026

Copy link
Copy Markdown

Description

Adds review support for Tera (.tera) templates, the Tera item of the Template Engines group in #470.

.tera files are currently skipped as unsupported_ext, and ocr rules check falls back to the generic default.md. This affects Rust web apps built with Rocket, which names Tera templates *.html.tera (see its official templating example).

Changes:

  • supported_file_types.json: add .tera
  • default_exclude_patterns.json: unchanged. Tera has no test-file convention (same as Pug); generic fixture exclusions still apply
  • New rule_docs/tera.md, registered as **/*.tera → tera.md in system_rules.json
  • review-rules.md mapping table updated in all locales (en, ja, ko, ru, tr, zh)

tera.md covers Tera-specific pitfalls rather than reusing jinja.md:

  • autoescaping is decided by the template name (.html, .htm, .xml by default), so page.html.tera is not escaped unless the host strips .tera or configures autoescape_on
  • an undefined variable fails the whole render, and default only applies to undefined values
  • {% set %} inside loops vs {% set_global %}
  • macros only see their own arguments; same-file calls need self::

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring (no functional changes)
  • Documentation update
  • CI / Build / Tooling

How Has This Been Tested?

  • make test passes locally

  • Manual testing (describe below)

  • make check passes (license headers, English-only check, gofmt, go vet)

  • make coverage passes (91.3%, threshold 90%)

  • Full go test ./... passes. make test could not run locally because -race requires cgo, which is not set up on my Windows machine

  • New tests: .tera / .TERA in TestIsAllowedExt; IsExcludedPath cases (fixture excluded, templates/page.html.tera and tests/templates/page.tera still reviewed); TestResolve_DefaultRules cases for page.html.tera, base.tera and page.HTML.TERA

  • Manually checked with ocr delegate preview on main: templates/page.html.tera was excluded as unsupported_ext before this change

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable)
  • I have signed the CLA
  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

AI disclosure: I used Claude Code (Claude Opus 5.5) to help with the implementation and the rule doc. I reviewed every line and checked the rule doc against the official Tera documentation.

Related Issues

Closes #2154
Part of #470

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

OpenCodeReview · Complete review: 2 of 2 selected files covered

0 findings.

Review info

Reviewed commits: 673331c2451928d29fb3115ddb2a3865d6c404ab → 4ebf597778a9196442a82c1d0bcb6c6bb1330220

File Result
internal/config/rules/system_rules.json Reviewed
internal/config/allowlist/supported_file_types.json Reviewed

This branch has not been deployed

No deployments
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.

feat(allowlist): add Tera (.tera) template support

1 participant