<div class="my-2 {{class}}" {{#if id}}id="{{id}}"{{/if}}>
    <a href="data:text/csv;charset=UTF-8,
    {{~#if bom~}}
        %EF%BB%BF{{! Byte order mark for Excel }}
    {{~/if~}}
{{~#each_row~}}
        {{~#if (eq @row_index 0)~}}{{! header }}
            {{~#each this~}}
                {{~url_encode (csv_escape @key ../../separator)~}}
                {{~#if (not @last)~}}
                    {{default ../../separator ","}}
                {{~/if~}}
            {{~/each~}}
        %0A{{! %0A = newline}}
        {{~/if~}}
        {{~#each this~}}
            {{~url_encode (csv_escape this ../../separator)~}}
            {{~#if (not @last)~}}
                {{default ../../separator ","}}
            {{~/if~}}
        {{~/each~}}
    %0A
{{~/each_row~}}
"
       download="{{default filename title}}.csv"
       class="btn btn-{{default color "primary"}}{{#if size}} btn-{{size}}{{/if}}">
        {{~icon_img (default icon "download")~}}
        {{default title "Download"}}
    </a>
</div>
