feat: add architecture rules for macro API changes
Added TPL-013 and TPL-014 rules to detect deprecated macro usage:
TPL-013: Use new pagination macro API
- Detects old parameters: current_page, total_pages, page_numbers, etc.
- New API only accepts show_condition parameter
- Component must provide standardized Alpine.js properties
TPL-014: Use new modal_simple macro API with call block
- Detects {{ modal_simple( instead of {% call modal_simple( %}
- Detects deprecated parameters: icon, confirm_text, confirm_fn, etc.
- New API uses {% call %}...{% endcall %} with content in body
These rules will catch template issues at validation time rather than
at runtime, preventing the TypeError crashes we saw.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -530,6 +530,76 @@ template_rules:
|
||||
exceptions:
|
||||
- "base.html"
|
||||
|
||||
- id: "TPL-013"
|
||||
name: "Use new pagination macro API"
|
||||
severity: "error"
|
||||
description: |
|
||||
The pagination macro was simplified to only accept show_condition.
|
||||
It now relies on standardized Alpine.js component properties.
|
||||
|
||||
OLD (deprecated - will break):
|
||||
{{ pagination(
|
||||
current_page='pagination.page',
|
||||
total_pages='totalPages',
|
||||
...
|
||||
) }}
|
||||
|
||||
NEW (correct):
|
||||
{{ pagination(show_condition="!loading && pagination.total > 0") }}
|
||||
|
||||
Required Alpine.js component properties:
|
||||
- pagination.page, pagination.total
|
||||
- totalPages, pageNumbers
|
||||
- startIndex, endIndex
|
||||
- previousPage(), nextPage(), goToPage()
|
||||
pattern:
|
||||
file_pattern: "app/templates/**/*.html"
|
||||
anti_patterns:
|
||||
- "pagination\\s*\\([^)]*current_page\\s*="
|
||||
- "pagination\\s*\\([^)]*total_pages\\s*="
|
||||
- "pagination\\s*\\([^)]*page_numbers\\s*="
|
||||
exceptions:
|
||||
- "shared/macros/pagination.html"
|
||||
|
||||
- id: "TPL-014"
|
||||
name: "Use new modal_simple macro API with call block"
|
||||
severity: "error"
|
||||
description: |
|
||||
The modal_simple macro now uses {% call %}...{% endcall %} syntax.
|
||||
Content (including buttons) goes inside the call block.
|
||||
|
||||
OLD (deprecated - will break):
|
||||
{{ modal_simple(
|
||||
show_var='showModal',
|
||||
title='Title',
|
||||
icon='exclamation',
|
||||
confirm_text='OK',
|
||||
confirm_fn='doSomething()'
|
||||
) }}
|
||||
<template x-if="showModal">...</template>
|
||||
|
||||
NEW (correct):
|
||||
{% call modal_simple('modalId', 'Title', show_var='showModal') %}
|
||||
<div class="space-y-4">
|
||||
<p>Modal content here</p>
|
||||
<div class="flex justify-end gap-3">
|
||||
<button @click="showModal = false">Cancel</button>
|
||||
<button @click="doSomething()">OK</button>
|
||||
</div>
|
||||
</div>
|
||||
{% endcall %}
|
||||
|
||||
Parameters: modal_simple(id, title, show_var='isModalOpen', size='md')
|
||||
pattern:
|
||||
file_pattern: "app/templates/**/*.html"
|
||||
anti_patterns:
|
||||
- "\\{\\{\\s*modal_simple\\s*\\("
|
||||
- "modal_simple\\s*\\([^)]*icon\\s*="
|
||||
- "modal_simple\\s*\\([^)]*confirm_text\\s*="
|
||||
- "modal_simple\\s*\\([^)]*confirm_fn\\s*="
|
||||
exceptions:
|
||||
- "shared/macros/modals.html"
|
||||
|
||||
# ============================================================================
|
||||
# FRONTEND COMPONENT RULES
|
||||
# ============================================================================
|
||||
|
||||
Reference in New Issue
Block a user