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

CommentFileSizeAuthor
#2 office_hours_3384240_spaceless.patch1020 bytesjohnv

Comments

johnv created an issue. See original summary.

johnv’s picture

Status: Active » Needs review
StatusFileSize
new1020 bytes

  • johnv committed 8f9ae942 on 8.x-1.x
    Issue #3384240 by johnv: Remove white space in plain text formatter
    
johnv’s picture

Status: Needs review » Fixed

  • johnv committed 1a37414f on 8.x-1.x
    Issue #3384240: Remove white space in plain text formatter - Add README....

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.