When you call any snippet or Block using a Jinja reference and the object you are referencing contains multiple lines of Jinja code, it can add extra white space to the output.
Suppose you want to ensure the object's Jinja reference doesn't add any extra undesired whitespace. You can use "-" when opening or closing Jinja tags inside the referenced object.
Example
{%- set priceAsString = params.price | string -%}
{%- set priceSplit = priceAsString.split('.') -%}
{%- set priceInteger = priceSplit[0] -%}
{%- set priceFraction = '' -%}
{%- if priceSplit | count > 1 -%}
{%- set priceFraction = priceSplit[1] -%}
{%- if priceFraction | length < params.decimalPlaces -%}
{%- set priceFraction = priceFraction.ljust(params.decimalPlaces, '0') -%}
{%- else -%}
{%- set priceFraction = priceFraction[:params.decimalPlaces] -%}
{%- endif -%}
{%- endif -%}
{%- set formattedPrice = priceInteger | reverse | batch(3) | map('join', '') | join(params.thousandSeparator) | reverse -%}
{%- if priceFraction != '' -%}
{%- set formattedPrice = formattedPrice ~ params.decimalSeparator ~ priceFraction -%}
{%- endif -%}
{% if params.currencyPosition == 'leading' %}
{{- params.currency ~ formattedPrice}}
{% elif params.currency %}
{{- formattedPrice ~ ' ' ~ params.currency -}}
{%- endif -%}Adding "-" ensures that the line of code doesn't create unnecessary whitespace, which can be undesired, for example, in the email campaign's subject line.
How to remove whitespace in Visual Builder when using Jinja reference?
When using Jinja references in our Visual Builder, adding a hyphen ("-") to remove whitespace will not be effective. This is because the Visual Builder automatically adds a "<br>" tag for any new line breaks in the HTML it generates.
To eliminate whitespace within the visual editor, you must compress the Jinja code so there are no line breaks or spaces between individual lines.
This means you should place all the code on a single line within the Block you insert it into (for example, in the Title, Paragraph, or List blocks).