title: How should I render YAML arrays neatly with cookiecutter?
body: <p>I have a cookiecutter template that I want to render a YAML file based on some options.</p>
  
  <p>As a simple example, suppose a rendered YAML file could look like this:</p>
  
  <pre><code>supported_databases:
    - mysql
    - postgres
  </code></pre>
  
  <p>And my cookiecutter JSON looked like this:</p>
  
  <pre><code>{
    "mysql": ["yes", "no"],
    "postgres": ["yes", "no"]
  }
  </code></pre>
  
  <p>My YAML file is going to be horribly peppered with <code>if</code>s to support all 4 valid combinations:</p>
  
  <pre><code>{%- if cookiecutter.mysql == 'yes' or cookiecutter.postgres == 'yes' %}
  supported_databases:
  {%- if cookiecutter.mysql == 'yes' %}
    - mysql
  {%- endif %}
  {%- if cookiecutter.mysql == 'yes' %}
    - postgres
  {%- endif %}
  {%- endif %}
  </code></pre>
  
  <p>The outer <code>if</code> is required to prevent invalid YAML being rendered in the case when both options are 'no'.</p>
  
  <p>Is there a neater way to accomplish this?</p>
  
  <p>Thanks for any help.</p>