mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-02 17:48:50 -04:00
error when users put non-GSM chars in a sms template
additionally, this moves the formatted_list jinja macro into a python function, so that it can be called from the form validator
This commit is contained in:
@@ -1,35 +1,5 @@
|
||||
{% macro formatted_list(
|
||||
items,
|
||||
conjunction='and',
|
||||
before_each='‘',
|
||||
after_each='’',
|
||||
separator=', ',
|
||||
prefix='',
|
||||
prefix_plural=''
|
||||
) %}
|
||||
{% if items|length == 1 %}
|
||||
{{ prefix }} {{ before_each|safe }}{{ (items|list)[0] }}{{ after_each|safe }}
|
||||
{% elif items %}
|
||||
{{ prefix_plural }}
|
||||
{% for item in (items|list)[0:-1] -%}
|
||||
{{ before_each|safe -}}
|
||||
{{ item -}}
|
||||
{{ after_each|safe -}}
|
||||
{% if not loop.last -%}
|
||||
{{ separator -}}
|
||||
{% endif -%}
|
||||
{% endfor %}
|
||||
{{ conjunction }}
|
||||
{{ before_each|safe -}}
|
||||
{{ (items|list)[-1] -}}
|
||||
{{ after_each|safe }}
|
||||
{%- endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
|
||||
{% macro list_of_placeholders(placeholders) %}
|
||||
{{ formatted_list(
|
||||
placeholders,
|
||||
{{ placeholders | formatted_list(
|
||||
before_each="<span class='placeholder'>((",
|
||||
after_each='))</span>',
|
||||
separator=' '
|
||||
|
||||
Reference in New Issue
Block a user