Skip to content

feat: add template validation using askama_parser#3940

Merged
yujonglee merged 3 commits intomainfrom
feat/askama-template-validation
Feb 13, 2026
Merged

feat: add template validation using askama_parser#3940
yujonglee merged 3 commits intomainfrom
feat/askama-template-validation

Conversation

@yujonglee
Copy link
Contributor

@yujonglee yujonglee commented Feb 13, 2026

Summary

Add runtime template parsing and validation using askama_parser.

Changes

crates/askama-utils

  • extract(src) — Parses a template string and walks the AST to collect all referenced variables and filter names
  • TemplateUsage — Struct with variables and filters HashSets
  • Added askama_parser dependency

crates/template-app

  • validate(src, allowed_variables) — Validates that a template only uses allowed variables and the 4 custom filters (current_date, language, is_english, is_korean)
  • ValidationError — Contains unknown_variables and unknown_filters for error reporting
  • Extended Error enum with ParseError and ValidationError variants

Usage

use template_app::validate;

// Validate a user-provided template against allowed vars
let result = validate(
    r#"{{ name|language }}, today is {{ ""|current_date }}"#,
    &["name"],
);

Open with Devin

yujonglee and others added 3 commits February 13, 2026 11:19
- Add extract() to askama-utils: parses template strings and collects
  variables and filters from the AST
- Add validate() to template-app: validates templates against allowed
  variables and custom filters (current_date, language, is_english,
  is_korean)
- Add askama_parser as workspace dependency

Co-authored-by: Cursor <cursoragent@cursor.com>
@netlify
Copy link

netlify bot commented Feb 13, 2026

Deploy Preview for hyprnote-storybook canceled.

Name Link
🔨 Latest commit f608d5e
🔍 Latest deploy log https://app.netlify.com/projects/hyprnote-storybook/deploys/698ea6f03f3dac000848efa0

@netlify
Copy link

netlify bot commented Feb 13, 2026

Deploy Preview for hyprnote ready!

Name Link
🔨 Latest commit f608d5e
🔍 Latest deploy log https://app.netlify.com/projects/hyprnote/deploys/698ea6f0717fad0008f2146f
😎 Deploy Preview https://deploy-preview-3940--hyprnote.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 7 additional findings.

Open in Devin Review

@yujonglee yujonglee merged commit d9cb8d0 into main Feb 13, 2026
22 checks passed
@yujonglee yujonglee deleted the feat/askama-template-validation branch February 13, 2026 04:29
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