Developer Guide

This document is intended for developers who want to understand, extend, or contribute to CandidTemplate.

---

1. Core Philosophy

Structure → Composition → Binding → Rendering
---

2. Core Classes

ClassResponsibility
CandidTemplateAdaptor Entry point (bind, slot, include)
CandidTemplate Main engine (slots, loops, render)
CandidDomContext DOM parsing + rendering
CandidElement Fluent API (content, attribute)
---

3. Rendering Pipeline

Load DOM
   ↓
Register slots/includes
   ↓
Execute data files
   ↓
Render includes (pass 1)
   ↓
Render slots (recursive)
   ↓
Render includes (pass 2)
   ↓
Process loops
   ↓
Apply assignments
   ↓
Output HTML
---

4. Key Design Decisions

---

5. Template Hierarchy

Base Template
   ↓
Child Template (slot)
   ↓
Nested Template
---

6. Data Flow

set() → local
get() → local + parent
share() → global (root)
---

7. Extension Points

Developers can extend: ---

8. Planned Features (Roadmap)

---

9. Coding Guidelines

---

10. Error Handling Strategy

---

11. Testing Strategy

---

12. Performance Considerations

---

13. Contribution Guidelines

---

14. Debugging Tips

---

15. Versioning Strategy

---

16. Component System (Planned)

Components will be defined using data-component attributes.

---
Example

<div data-component="card"></div>

$tpl->component('card', 'card-template');
---
Concept
---
Why not custom tags?
Using data-component keeps HTML valid and avoids parser issues.
This document ensures long-term maintainability and contributor clarity.