Problem/Motivation
Thank you for this module that is very close to matching a use case of mine, except that my data is author names in a multiple value text field, and Inotherwords requires the field to be a text list. Attached is a patch that adds a formatter for string fields.
Since processed_text
ends up wrapped in <p>
tags, I needed to do some twig processing is well. There is probably a better way, but the twig became:
{% apply spaceless %}
{{ text_before -}}
{% for item in items %}{{- item|render|striptags|trim(side='right')|replace({',': ', ', 'and': ' and '}) -}}{% endfor %}
{{- text_after|striptags('<a>')|raw }}
{% endapply %}
This is because after striptags to remove
there was extra spacing around the items, so I had to trim then selectively restore the original spacing (not ideal). The text_after|striptags('<a>')|raw
is because I have a hyperlink in my 'after' text.
Remaining tasks
- Update implementation so items aren't wrapped in
<p>
tags.
- Test
- Profit (in the non-commercial, open-source sense of the word)
User interface changes
Adds In Other Words: List formatter option to string fields.
API changes
None
Data model changes
None