Drupal Render API
Philosophy: Configuration First -- Prioritize render arrays (the declarative approach) over raw HTML output. Render arrays are data structures that get processed, cached, and themed automatically.
I need to...
| Task | Guide |
|---|---|
| Understand when to use render arrays vs other approaches | Render API Overview |
| Learn render array structure and syntax | Render Array Structure |
| Know what #type, #theme, #markup mean | Render Properties |
| Find the right render element for my output | Core Render Elements |
| Use form elements outside forms | Form Render Elements |
| Attach CSS/JS libraries to my render array | Attachments |
| Add cache metadata to improve performance | Cache Metadata in Render Arrays |
| Use the Renderer service programmatically | The Renderer Service |
| Pass render arrays to Twig templates | Twig Integration |
| Modify variables before they reach Twig | Preprocess Functions |
| Create theme hooks and suggestions | Theme Hooks & Suggestions |
| Defer expensive rendering for better caching | Lazy Builders & Placeholders |
| Create my own render element plugin | Custom Render Elements |
| See common render array patterns | Render Array Patterns |
| Understand main content renderers | Main Content Renderers |
| Follow best practices | Best Practices & Patterns |
| Avoid common mistakes | Anti-Patterns & Common Mistakes |
| Ensure security and performance | Security & Performance |
| Find core render files and documentation | Code Reference Map |