Force example CSV to download, not open in browser

We wouldn’t wan’t anyone just seeing the raw CSV data in their browser – it isn’t clear what a user would do with it at that point. And we wouldn’t want it navigating them away from the send page, because this might cause them to lose their place.

This commit forces the file to download using the HTML5 `download` attribute:

> This attribute instructs browsers to download a URL instead of navigating to it, so the user will be prompted to save it as a local file. 

– https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-download
This commit is contained in:
Chris Hill-Scott
2018-01-02 14:06:39 +00:00
committed by GitHub
parent 538e3f8097
commit 85b3978061

View File

@@ -40,7 +40,7 @@
{% endcall %}
</div>
<p class="table-show-more-link">
<a href="{{ url_for('.get_example_csv', service_id=current_service.id, template_id=template.id) }}">Download this example</a>
<a href="{{ url_for('.get_example_csv', service_id=current_service.id, template_id=template.id) }}" download="download">Download this example</a>
</p>
<h2 class="heading-medium">Your file will populate this template ({{ template.name }})</h2>