How remove whitespace on field in twig? I try to print field value in a node--template.html.twig without whitespace.
This field is a select in admin page.

Location|Location 
Achat|Achat


This is how my value is print : 


  {{ content.field_type }}





  field.html.twig :


{% for item in items %}
{{- item.content -}}
{%  endfor %}


I try some twig argument like 


  {{content.field_type|trim}}


But when i print like this, it's empty.

So where are this whitespace ? same if i try to test the value in if else condition :

This doesn't work because of whitespace : 


  {% if  content.field_type == "Achat" %}


This work :


  {% if  content.field_type|render|trim == "Achat" %}


So for test a value it's ok, but for print the value if i use 


  {{content.field_type|render|trim}}


i got same result with whitespace.

So if someone can tell me where is add this whitespace and how remove this in twig.
I use the boostrap theme, but i don't see anything who add whitespace.
It sounds to me that you have a template, probably field.html.twig that is adding this space. You can enable the twig debug to see which templates' files are used.

Also, I think it's better to test the value on node.field.value instead of content.field as it's done for the rendering only.

Note that the twig operators as {% for ... %} also add spaces, so you should add - as well in there for e.g.:

{%- for item in items %}
{{ item.content }}
{%  endfor -%}