1

Following situation:

I have a inline-block title with a background gradient applied. So in order that the background always starts from the left, each line will have to be spanned by a span tag.

Welcome to<br /> 
our site

should become this:

<span>Welcome to</span><br /> 
<span>our site</span>

I've started with this:

{{ block.heroTitle|nl2br }} 

But I'm stuck.
Any help appreciated.

1

You can split your text

{% set text = block.heroTitle|nl2br %}
{% set splited = text|split('<br />')%}
{% for part in splited %}
    <span>{{ part }}</span>
{% endfor %}

If you need you can use the trim filter as well

<span>{{ part|trim }}</span>
1
  • That was exactly was I was after! Thanks a lot! – outline4 Mar 8 '18 at 16:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.