Skip to content

Comments

feat(template): add dynamic variables and conditionals to ban templates#133

Draft
LaurenceJJones wants to merge 4 commits intocrowdsecurity:mainfrom
LaurenceJJones:feature/expanded-templating
Draft

feat(template): add dynamic variables and conditionals to ban templates#133
LaurenceJJones wants to merge 4 commits intocrowdsecurity:mainfrom
LaurenceJJones:feature/expanded-templating

Conversation

@LaurenceJJones
Copy link
Member

WIP

  • Add if/else conditional support: {{#if var}}...{{else}}...{{/if}}
  • Add negation support: {{#if !var}}...{{/if}}
  • Add dynamic variables: client_ip, request_id, timestamp, etc.
  • Add template documentation in templates/README.md

LaurenceJJones and others added 4 commits January 19, 2026 10:41
- Add if/else conditional support: {{#if var}}...{{else}}...{{/if}}
- Add negation support: {{#if !var}}...{{/if}}
- Add dynamic variables: client_ip, request_id, timestamp, etc.
- Add template documentation in templates/README.md

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Parse template structure once at startup
- Only variable substitution happens at request time
- Improves performance for ban page rendering

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Move get_request_vars() to template module
- Use nginx native request_id instead of custom generator
- Both ban and captcha now use shared helper

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add @Class, @field, @param, @return annotations
- Helps with LSP autocomplete and type checking
- Documents function signatures and data structures

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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