---
id: {{ id }}
type: pattern
title: {{ title }}
created: {{ created }}
modified: {{ modified }}
tags: [{% for tag in tags %}"{{ tag }}"{% if not loop.last %}, {% endif %}{% endfor %}]
status: {{ status | default(value="active") }}
{% if relates_to and relates_to | length > 0 -%}
relates_to:
{% for rel in relates_to %}  - {{ rel }}
{% endfor %}
{%- endif %}
{% if depends_on and depends_on | length > 0 -%}
depends_on:
{% for dep in depends_on %}  - {{ dep }}
{% endfor %}
{%- endif %}
{% if project -%}
project: {{ project }}
{% endif -%}
problem: |
  {{ problem | default(value="") | indent(width=2) }}
solution: |
  {{ solution | default(value="") | indent(width=2) }}
{% if forces and forces | length > 0 -%}
forces:
{% for force in forces %}  - {{ force }}
{% endfor %}
{%- endif %}
---

# {{ title }}

## Problem

{{ problem | default(value="TODO: Describe the problem this pattern solves") }}

## Context

{{ context | default(value="TODO: Describe when this pattern should be used") }}

{% if forces and forces | length > 0 %}
## Forces

{% for force in forces %}
- {{ force }}
{% endfor %}
{% endif %}

## Solution

{{ solution | default(value="TODO: Describe the solution/implementation") }}

{% if structure %}
## Structure

{{ structure }}
{% endif %}

{% if implementation and implementation | length > 0 %}
## Implementation

{% for step in implementation %}
{{ loop.index }}. **{{ step.title }}**
   {{ step.description }}
   {% if step.code %}
   ```{{ step.language | default(value="") }}
   {{ step.code }}
   ```
   {% endif %}
{% endfor %}
{% endif %}

{% if examples and examples | length > 0 %}
## Examples

{% for example in examples %}
### {{ example.title }}

{{ example.description }}

{% if example.code %}
```{{ example.language | default(value="") }}
{{ example.code }}
```
{% endif %}
{% endfor %}
{% endif %}

{% if consequences and consequences | length > 0 %}
## Consequences

### Benefits
{% for benefit in consequences.benefits %}
- {{ benefit }}
{% endfor %}

### Drawbacks
{% for drawback in consequences.drawbacks %}
- {{ drawback }}
{% endfor %}
{% endif %}

{% if related_patterns and related_patterns | length > 0 %}
## Related Patterns

{% for pattern in related_patterns %}
- [[{{ pattern }}]]
{% endfor %}
{% endif %}

{% if references and references | length > 0 %}
## References

{% for ref in references %}
- {{ ref }}
{% endfor %}
{% endif %}
