title: Unique Filter of List in Jinja2
body: <p>I have the following YAML structure:</p>
  
  <pre><code>bri:
    cards:
      - slot: "1"
        subslot: "0"
        ports: 2
      - slot: "1"
        subslot: "1"
        ports: 2
      - slot: "1"
        subslot: "2"
        ports: 2
      - slot: "2"
        subslot: "0"
        ports: 2
      - slot: "2"
        subslot: "1"
        ports: 2
  </code></pre>
  
  <p>I am attempting to use Jinja2 to get a unique list of <strong>slots</strong>, i.e.:</p>
  
  <pre><code>['1', '2']
  </code></pre>
  
  <p>So far, I've managed to apply the following:</p>
  
  <pre><code>{{ bri.cards|map(attribute='slot')|list }}
  </code></pre>
  
  <p>Which gives me:</p>
  
  <pre><code>['1', '1', '1', '2', '2']
  </code></pre>
  
  <p>However, I don't seem to be able to find a way to get a unique list.</p>
  
  <h3>Ansible</h3>
  
  <p>Ansible appears to have a "unique" filter that can do this.  But I'm not using Ansible in this case.</p>
  
  <ul>
  <li><a href="http://docs.ansible.com/ansible/playbooks_filters.html#set-theory-filters" rel="nofollow noreferrer">http://docs.ansible.com/ansible/playbooks_filters.html#set-theory-filters</a></li>
  <li><a href="https://stackoverflow.com/questions/36228816/ansible-jinja2-get-unique-subelements">ansible/jinja2 get unique subelements</a></li>
  </ul>
  
  <h3>My question</h3>
  
  <p>Can anyone suggest the best way to achieve this?  Should (or can) this be done natively with Jinja2, or should I adopt an alternative approach?</p>