Make components for nicely formatted lists

We have a couple of places now where we want nice lists made from `list`s, eg

- ‘name’, ‘date’ and ‘phone number’
- ((firstname)) ((lastname)) or ((date))

This commit adds a more generic component for doing this, which can handle:

- 1, 2, and n items
- comma (or other character) separated lists
- a conjunction between the last and one-before-last item
- characters to be inserted before and after each item, eg an opening and
  closing HTML tag

It also pulls the `list_of_placeholders` component from the breaking change
page, and makes it use the `formatted_list` component under the hood.
This commit is contained in:
Chris Hill-Scott
2016-06-03 14:30:17 +01:00
parent 3ace856d74
commit 9332f57f55
4 changed files with 71 additions and 31 deletions

View File

@@ -10,6 +10,7 @@
{% from "components/textbox.html" import textbox %}
{% from "components/file-upload.html" import file_upload %}
{% from "components/api-key.html" import api_key %}
{% from "components/list.html" import formatted_list %}
{% block page_title %}
Styleguide GOV.UK Notify
@@ -230,4 +231,23 @@
{{ api_key('d30512af92e1386d63b90e5973b49a10') }}
<h2 class="heading-large">Formatted list</h2>
<p>
{{ formatted_list('A', prefix="one item called") }}
</p>
<p>
{{ formatted_list('AB', prefix_plural="two items called") }}
</p>
<p>
{{ formatted_list('ABC') }}
</p>
<p>
{{ formatted_list('ABCD', before_each='<strike>', after_each='</strike>', conjunction='or') }}
</p>
{% endblock %}