{{ if [element:sortable] and [element:sort_by] == [element:attr] and [element:sort_direction] == 'desc'}}
<th {{ if [element:sortable] }}class="descending"{{endif }}{{ if [element:attrs] }} [element:attrs|raw]{{ endif }}>
  {{ if [element:value] }}
    [element:value]
  {{ endif }}
  <a href="[element:url]&sort_direction=ASC"></a>
{{ else }}
<th {{ if [element:sortable] }}class="ascending"{{endif }}{{ if [element:attrs] }} [element:attrs|raw]{{ endif }}>
  {{ if [element:value] }}
    [element:value]
  {{ endif }}
  <a href="[element:url]&sort_direction=DESC"></a>
{{ endif }}
  {{ if [element:children] }}
    {{ for child in [element:children] }}
      [child:render]
    {{ endfor }}
  {{ endif }}
</th>