Problem/Motivation
When generating HTML with a plain text formatter, without any class/div/span information, there are still additional spaces in the output.
Steps to reproduce
Create a Views view with Title, ID, office_hours fields;
- under Format/Format/Format, set to 'Unformatted list' of 'Fields'
- under Format/Format/Settings, unset 'Add views row classes'
- under Format/Show, set to 'Fields',
- Under Format/Show/Settings, set 'Provide default field wrapper elements' to be able to set all fields to 'Inline', adding ';' as a separator;
-- Then, unset 'Provide default field wrapper elements'. See #2715015: inline fields and field wrapper elements: UI unexpected behavior
- under Fields, set Office_hours formatter to 'plain text'. Set the days separator to ';', removing the default line break. Set other formatting options.
Now, for all fields, set the Views options to make the View as clean as possible:
- unset Link label to the referenced entity
- unset Style settings / Add default classes
- set Rewrite results / Strip HTML tags
- set Rewrite results / Remove whitespace (if needed)
Proposed resolution
The twig manual contains several options:
1. {% spaceless %} tag, which is outdated
2. {% apply spaceless %} filter
3. whitespace trimming using '-'
Some blogs:
https://symfony.com/blog/better-white-space-control-in-twig-templates
http://vvv.tobiassjosten.net/symfony/trim-and-remove-twig-whitespace/
API changes
after some testing, the {% apply spaceless %} filter is applied to the twig file
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | office_hours_3384240_spaceless.patch | 1020 bytes | johnv |
Comments
Comment #2
johnvComment #4
johnv