You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-5Lines changed: 10 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ Facet is a server-side rendering framework that maps REST API responses to HTML
13
13
```http
14
14
GET /shop/products
15
15
Accept: application/json → JSON response (REST API unchanged)
16
-
Accept: text/html → HTML rendered from templates/shop/products/index.html
16
+
Accept: text/html → HTML rendered from templates/shop/products/list.html
17
17
```
18
18
19
19
Templates are opt-in. Add HTML rendering only where you need it; your REST API continues working unchanged.
@@ -74,14 +74,19 @@ Here's the actual product list template from the example (simplified):
74
74
75
75
### Convention-Based Routing
76
76
77
-
Templates automatically resolve based on request path:
77
+
Templates automatically resolve based on request path with explicit action templates:
78
78
79
79
```http
80
-
GET /shop/products → templates/shop/products/index.html
81
-
GET /shop/products/123 → templates/shop/products/view.html
80
+
GET /shop/products → templates/shop/products/list.html (collection view)
81
+
GET /shop/products/123 → templates/shop/products/view.html (document view)
82
82
```
83
83
84
-
Hierarchical fallback: if `shop/products/index.html` doesn't exist, tries `shop/index.html`, then `index.html`.
84
+
**Naming convention:**
85
+
-**`list.html`** - Collection views (recommended - no conditional logic needed)
86
+
-**`view.html`** - Document views (recommended - no conditional logic needed)
87
+
-**`index.html`** - Optional fallback (when list/view can share template logic)
88
+
89
+
Hierarchical fallback: if `shop/products/list.html` doesn't exist, tries `shop/products/index.html`, then `shop/list.html`, then `shop/index.html`, finally `list.html` and `index.html`.
Copy file name to clipboardExpand all lines: docs/DEVELOPERS_GUIDE.md
+44-10Lines changed: 44 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ This guide provides a complete reference for Facet's features and capabilities.
9
9
10
10
Facet is a data-driven web framework that transforms JSON documents into server-rendered HTML through path-based templates. It's a RESTHeart plugin that provides **hybrid API/UI from the same endpoint**—JSON for API clients, HTML for browsers.
11
11
12
-
**Core principle**: Convention over Configuration. Your template structure mirrors your API paths. A request to `/mydb/products` automatically uses `templates/mydb/products/index.html` when the browser requests HTML.
12
+
**Core principle**: Convention over Configuration. Your template structure mirrors your API paths. A request to `/mydb/products`(collection) automatically uses `templates/mydb/products/list.html` or falls back to `index.html` when the browser requests HTML.
13
13
14
14
**Technology stack**:
15
15
-**[RESTHeart](https://restheart.org/)** - MongoDB REST API server (provides the plugin architecture, HTTP layer, auth, and more)
@@ -58,18 +58,46 @@ Accept: text/html
58
58
5. Browser receives HTML page
59
59
```
60
60
61
+
### Template Naming Convention
62
+
63
+
**Recommended Pattern (Explicit):**
64
+
-**`list.html`** - For collection views (recommended - clean, no conditional logic)
65
+
-**`view.html`** - For document views (recommended - clean, no conditional logic)
66
+
-**`index.html`** - Optional fallback (use when list/view can share template logic)
67
+
68
+
**Why explicit templates?** Templates are cleaner without conditional logic checking request type. File names clearly indicate purpose.
Copy file name to clipboardExpand all lines: docs/TUTORIAL_PRODUCT_CATALOG.md
+12-10Lines changed: 12 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -131,12 +131,12 @@ The `documents` variable contains all products from MongoDB.
131
131
132
132
### Template Naming Convention
133
133
134
-
Facet uses action-aware resolution:
134
+
Facet uses explicit action-aware resolution:
135
135
136
-
-**Collection requests** → looks for `list.html` first, then `index.html`
137
-
-**Document requests** → looks for `view.html` first, then `index.html`
136
+
-**Collection requests** → looks for `list.html` first, then `index.html` (optional fallback)
137
+
-**Document requests** → looks for `view.html` first, then `index.html` (optional fallback)
138
138
139
-
This is why our file is named `list.html`not `index.html`.
139
+
**Recommended:** Use explicit templates (`list.html` and `view.html`) for cleaner code without conditional logic. This example uses `list.html`for the collection view and `view.html` for the document view, keeping each template focused and simple.
140
140
141
141
---
142
142
@@ -253,10 +253,12 @@ When requesting `/shop/products/65abc123...`:
The create flow works similarly. Open [templates/shop/products/index.html](../examples/product-catalog/templates/shop/products/index.html) (lines 18-26):
706
+
The create flow works similarly. Open [templates/shop/products/list.html](../examples/product-catalog/templates/shop/products/list.html) (lines 18-26):
705
707
706
708
```html
707
709
<button hx-get="{{ path }}"
@@ -787,7 +789,7 @@ async function deleteProduct() {
787
789
### Key Files
788
790
789
791
- [templates/shop/products/view.html](../examples/product-catalog/templates/shop/products/view.html) - Product detail page with HTMX buttons
790
-
- [templates/shop/products/index.html](../examples/product-catalog/templates/shop/products/index.html) - Product list with "Add Product" button
792
+
- [templates/shop/products/list.html](../examples/product-catalog/templates/shop/products/list.html) - Product list with "Add Product" button
791
793
- [templates/_fragments/product-form.html](../examples/product-catalog/templates/_fragments/product-form.html) - Edit form (HTMX fragment)
792
794
- [templates/_fragments/product-new.html](../examples/product-catalog/templates/_fragments/product-new.html) - Create form (HTMX fragment)
0 commit comments