diff --git a/docs/development/architecture-rules.md b/docs/development/architecture-rules.md index 7f73d8d1..40b161cc 100644 --- a/docs/development/architecture-rules.md +++ b/docs/development/architecture-rules.md @@ -661,6 +661,36 @@ Show empty state when lists have no items. ``` +#### TPL-008: Use Valid Block Names +**Severity:** Error + +Templates must use block names that exist in their base template. Using undefined blocks silently fails (content is not rendered). + +**Valid Admin Template Blocks:** +- `title` - Page title +- `extra_head` - Additional head content (CSS, meta tags) +- `alpine_data` - Alpine.js component function name +- `content` - Main page content +- `extra_scripts` - Additional JavaScript + +```jinja +{# ✅ Good - Valid block names #} +{% block extra_scripts %} + +{% endblock %} + +{# ❌ Bad - Invalid block name (silently ignored!) #} +{% block page_scripts %} + +{% endblock %} +``` + +**Common mistakes detected:** +- `page_scripts` → use `extra_scripts` +- `scripts` → use `extra_scripts` +- `js` → use `extra_scripts` +- `head` → use `extra_head` + --- ### Jinja Macro Rules (app/templates/**/*.html) @@ -969,6 +999,8 @@ Before committing code: | Business logic in endpoint | Move to service layer | | console.log in JS | Use `window.LogConfig.createLogger()` | | Missing ...data() | Add spread operator in component return | +| Missing currentPage | Add `currentPage: 'page-name'` in component return | +| Invalid block name | Use valid block: `extra_scripts`, `extra_head`, etc. | | Bare except clause | Specify exception type | | Raw dict return | Create Pydantic response model | | Template not extending base | Add `{% extends %}` or `{# standalone #}` marker | @@ -1002,16 +1034,16 @@ All rules are defined in `.architecture-rules.yaml`. To modify rules: |----------|-------|--------|----------| | Backend | 20 | 15 | 5 | | Frontend JS | 7 | 6 | 1 | -| Frontend Templates | 7 | 3 | 4 | +| Frontend Templates | 8 | 4 | 4 | | Frontend Macros | 5 | 2 | 3 | | Frontend Components | 1 | 0 | 1 | | Frontend Styling | 4 | 1 | 3 | | Naming | 5 | 3 | 2 | | Security | 5 | 5 | 0 | | Quality | 3 | 2 | 1 | -| **Total** | **57** | **37** | **20** | +| **Total** | **58** | **38** | **20** | --- -**Last Updated:** 2025-12-07 -**Version:** 2.3 +**Last Updated:** 2025-12-21 +**Version:** 2.4