Template Rendering
Render templates with built-in or external engines including Moro, Handlebars, and EJS with support for layouts and helpers.
Basic Template Rendering
MoroJS provides built-in template rendering middleware with support for multiple template engines.
Configure Template Engine
typescript
Template Engines
- •
moro- Built-in Moro template engine - •
handlebars- Handlebars template engine - •
ejs- EJS template engine - • Support for layouts and partials
- • Custom helpers and filters
- • Template caching for performance
Template Engines
Using Handlebars
typescript
Using EJS
typescript
Moro Template Syntax
typescript
Best Practices
Do
- • Enable template caching in production
- • Use layouts for consistent structure
- • Create reusable partials
- • Escape user input in templates
- • Use helpers for complex logic
- • Organize templates by feature
Don't
- • Put complex logic in templates
- • Disable caching in production
- • Trust user input without escaping
- • Mix template engines
- • Create deeply nested templates
- • Skip template validation