Template System Overview
Learn about moclojer's powerful template system that allows you to create dynamic responses based on request data, making your mocks more realistic and flexible.
What are templates?
- endpoint:
method: GET
path: /users/:id
response:
body: >
{
"id": "{{path-params.id}}",
"name": "User {{path-params.id}}",
"timestamp": "{{now}}"
}{
"id": "123",
"name": "User 123",
"timestamp": "2024-01-15T10:30:00Z"
}Why use templates?
🎯 Realistic Testing
🔄 Dynamic Responses
🧪 Flexible Testing
Template Variables
Path Parameters
Query Parameters
JSON Body Parameters
Request Headers
Built-in Functions
Common Patterns
Echo Responses
Personalized Responses
Search Results
API Keys and Authentication
Template Best Practices
1. Use Meaningful Names
2. Handle Missing Values
3. Keep Templates Readable
4. Use Consistent Formatting
Advanced Template Features
Nested Object Access
Conditional Content
Array Handling
Error Handling
What's Next?
Examples in Action
Need Help?
Last updated
Was this helpful?