How to use Twig-template for method's Explanatory Text?

How to use Twig-template for method's Explanatory Text?

Twig-template allows you to customize method's Explanatory Text depending on the presence of supported variable values such as:
  1. Estimated delivery dates:
    1. "from" - {{delivery_from}}
    2. "to" - {{delivery_to}}
  2. Estimated International duties & taxes - {{tax_amount}}
Allowed tags: if, for.
Filters: default, format_number, replace, round, trim, lower, upper, capitalize, title, date, date_modify.
Learn more about Twig-templates.

Example 1:
If there are estimated delivery dates configured for the shipping method you may set Explanatory Text with variables:
Estimated delivery from {{delivery_from}} to {{delivery_to}}.

If there are no estimated delivery dates configured for the shipping method you may alter Explanatory Text to:
Delivery within 10 business days. 

The Twig-template will be the following:
  1. {% if delivery_from and delivery_to %}
  2.     Estimated delivery from {{delivery_from}} to {{delivery_to}}.
  3. {% else %}
  4.     Delivery within 10 business days.
  5. {% endif %}
Example 2:
If there are estimated international duties & taxes configured for the shipping method you may set Explanatory Text with the variable:
Duties & taxes included - {{tax_amount}.

If there are no estimated international duties & taxes got from the carrier for the shipping method you may alter Explanatory Text to:
No duties & taxes included.

The Twig-template will be the following:
  1. {% if tax_amount is not null %}
  2.     Duties & taxes included - {{tax_amount}}.
  3. {% else %}
  4.     No duties & taxes included.
  5. {% endif %}
You may also combine those variables in a single Twig-template for Explanatory Text:
  1. {% if delivery_from and delivery_to %}
  2.     Estimated delivery from {{delivery_from}} to {{delivery_to}}.
  3. {% else %}
  4.     Delivery within 10 business days.
  5. {% endif %}
  6. {% if tax_amount is not null %}
  7.     Duties & taxes included - {{tax_amount}}.
  8. {% else %}
  9.     No duties & taxes included.
  10. {% endif %}