feat: add architecture rule TPL-015 for page_header macro API
Detects deprecated buttons=[] parameter usage in page_header macro.
Correct API:
- Single button: action_label, action_icon, action_onclick
- Multiple buttons: use page_header_flex with {% call %}
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -561,6 +561,39 @@ template_rules:
|
||||
exceptions:
|
||||
- "shared/macros/pagination.html"
|
||||
|
||||
- id: "TPL-015"
|
||||
name: "Use correct page_header macro API"
|
||||
severity: "error"
|
||||
description: |
|
||||
The page_header macro does not accept a buttons=[] parameter.
|
||||
Use action_label/action_onclick for a single action button,
|
||||
or use page_header_flex with {% call %} for multiple buttons.
|
||||
|
||||
OLD (deprecated - will break):
|
||||
{{ page_header('Title', buttons=[
|
||||
{'text': 'Add', 'icon': 'plus', 'click': 'doSomething()'}
|
||||
]) }}
|
||||
|
||||
NEW (single action button):
|
||||
{{ page_header('Title', action_label='Add', action_icon='plus', action_onclick='doSomething()') }}
|
||||
|
||||
NEW (multiple buttons - use page_header_flex):
|
||||
{% call page_header_flex(title='Title') %}
|
||||
<button @click="action1()">Button 1</button>
|
||||
<button @click="action2()">Button 2</button>
|
||||
{% endcall %}
|
||||
|
||||
Parameters for page_header:
|
||||
- title, subtitle
|
||||
- action_label, action_url, action_icon, action_onclick
|
||||
- back_url, back_label
|
||||
pattern:
|
||||
file_pattern: "app/templates/**/*.html"
|
||||
anti_patterns:
|
||||
- "page_header\\s*\\([^)]*buttons\\s*="
|
||||
exceptions:
|
||||
- "shared/macros/headers.html"
|
||||
|
||||
- id: "TPL-014"
|
||||
name: "Use new modal_simple macro API with call block"
|
||||
severity: "error"
|
||||
|
||||
Reference in New Issue
Block a user