docs
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
ViewData is the **only** allowed input type for Templates in `apps/website`.
|
||||
|
||||
Authoritative contract: [`WEBSITE_CONTRACT.md`](docs/architecture/website/WEBSITE_CONTRACT.md:1).
|
||||
|
||||
## 1) Definition
|
||||
|
||||
ViewData is a JSON-serializable, template-ready data structure:
|
||||
@@ -14,7 +16,7 @@ ViewData is a JSON-serializable, template-ready data structure:
|
||||
|
||||
ViewData is not:
|
||||
|
||||
- a Page DTO (raw transport)
|
||||
- an API Transport DTO (raw transport)
|
||||
- a ViewModel (client-only class)
|
||||
- a Display Object instance
|
||||
|
||||
@@ -25,8 +27,13 @@ ViewData MUST be created in client code:
|
||||
1) Initial SSR-safe render: `ViewData = fromDTO(PageDTO)`
|
||||
2) Post-hydration render: `ViewData = fromViewModel(ViewModel)`
|
||||
|
||||
These transformations are Presenters.
|
||||
See [`PRESENTERS.md`](docs/architecture/website/PRESENTERS.md:1).
|
||||
|
||||
Templates MUST NOT compute derived values.
|
||||
|
||||
Presenters MUST NOT call the API.
|
||||
|
||||
## 4) Determinism rules
|
||||
|
||||
Any formatting used to produce ViewData MUST be deterministic.
|
||||
@@ -38,9 +45,11 @@ Forbidden anywhere in formatting code paths:
|
||||
|
||||
Reason: SSR and browser outputs can differ.
|
||||
|
||||
Localization MUST NOT depend on runtime locale APIs.
|
||||
If localized strings are required, they MUST be provided as deterministic inputs (for example via API-provided labels or a deterministic code-to-label map) and passed through Presenters into ViewData.
|
||||
|
||||
## 5) Relationship to Display Objects
|
||||
|
||||
Display Objects are used to implement formatting/mapping, but their instances MUST NOT be stored inside ViewData.
|
||||
|
||||
Only primitive outputs produced by Display Objects may appear in ViewData.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user