Skip to content

feat: Simplify filter decorator with pass_build_env option#23

Merged
SilverRainZ merged 1 commit into
masterfrom
feat/simplify-filter-decorator
Jun 19, 2026
Merged

feat: Simplify filter decorator with pass_build_env option#23
SilverRainZ merged 1 commit into
masterfrom
feat/simplify-filter-decorator

Conversation

@SilverRainZ

Copy link
Copy Markdown
Member

Summary

  • Simplify the @filter decorator by adding a pass_build_env parameter
  • When pass_build_env=True, the filter receives BuildEnvironment as its first argument
  • Eliminates the need for factory functions in filter definitions
  • Updated existing filters and documentation to use the new API

Changes

  • Modified JinjaRegistry to store (func, needs_env) tuples instead of factory functions
  • Added pass_build_env parameter to @filter decorator
  • Updated _JinjaEnv to inject environment when pass_build_env=True
  • Migrated existing filters (roles, jsonify, catify) to new API
  • Added documentation examples for pass_build_env usage

Testing

  • All existing tests pass
  • Doctests pass
  • Verified filter functionality with new API

The @filter decorator now supports a pass_build_env parameter. When set to True, the filter receives BuildEnvironment as its first argument, eliminating the need for factory functions.

Co-authored-by: MiMoCode <mimo@xiaomi.com>
@SilverRainZ SilverRainZ force-pushed the feat/simplify-filter-decorator branch from fc18329 to 7e6a838 Compare June 19, 2026 10:24
@SilverRainZ SilverRainZ merged commit dee0acc into master Jun 19, 2026
6 checks passed
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