Search code examples
shopifyliquidremoving-whitespace

Trouble stripping whitespace in Shopify/Liquid


I should be able to do <p>{%- assign x = "aa, bb, cc" -%}{{- x -}}</p> and get aa,bb,cc as the output. Instead I'm getting aa, bb, cc.

i also tried {% assign x = "aa, bb, cc" | strip %} and got the same results.

Any ideas as to what's going wrong?


Solution

  • You are only removing the white spaces outside your string. Try:

     `{{ x | remove:" "}}`
    

    or for removing only the space next to the coma

     {{ x | replace: "," , " "}}
    

    :)