Remove trailing whitespace from a field Here is a slice of code from my twig template, which outputs the contents of some fields into a p tag:

&lt;p&gt;
    {{ content.field_story_program_name }},
    {{ content.field_story_relationship}},
    {{ content.field_story_city }}, 
    {{ content.field_story_state }}
&lt;/p&gt;


The output on the page renders a trailing white space after each field's content, which I don't want (because it creates spaces before the commas):


  Local Head Start Program Provider , Head Start administrator , Los Angeles , CA 


Things I've tried:


Based on this post, I checked my field.html.twig template to see if it's introducing spaces (it's not).
Tried putting a - in the {% endfor %} on that field.html.twig template anyway to see if it would help: {% endfor -%} (it didn't).
Put all of my values on one line in case a carriage return was being interpreted as whitespace (I think that was a Drupal 7 issue that I read) as in:
{{ content.field_story_first_name }} {{ content.field_story_last_name }}, {{ content.field_story_program_name }}, ...etc
But that didn't fix it
Tried {% spaceless %} though I know it's just for spaces between tags and so of course that didn't end up helping
Using the |trim Twig filter, which makes the entire value disappear and produces a rendering error. I suppose that technically solves the whitespace problem...  ;)


Can anyone help give me a clue? I would like to either


Find out where the extra space is coming from and turn it off there, or
Use the appropriate Twig filter to remove the space
Okay, here is what finally worked: wrap every individual field in {% spaceless %} (not just the whole block) and use render and trim together.  Trim alone makes the variable disappear. Here's my markup:

&lt;p&gt;
  {% spaceless %}{{ content.field_story_program_name|render|trim }}{% endspaceless %},
  {% spaceless %}{{ content.field_story_relationship|render|trim }}{% endspaceless %},
  {% spaceless %}{{ content.field_story_city|render|trim }}{% endspaceless %}, 
  {{ content.field_story_state }}
&lt;/p&gt;


Extra thanks to @Cyclonecode for giving me a variety of tricks to try.