如何使用TWIG将地址代码放在一行上? [英] How to make the address code on one line with TWIG?
本文介绍了如何使用TWIG将地址代码放在一行上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个TWIG代码来显示商店的地址.
当前地址显示在3行上.
如何将地址代码放在一行上?
{{ store.address|render|trim|replace({'<br>': ' - '})|striptags|raw }}
解决方案
您正在输出<pre>
标记内的地址.默认情况下,<pre>
标记的white-space
设置为pre
.有关更多信息,请参见此处. >
所以您有2个选择
- 将
<pre>
标记替换为<div>
<div>
Lorem
ipsum
dolor
sit
amet
</div>
- 用
css
取代<pre>
的white-space
pre.spaceless {
white-space: normal;
}
<pre>
Lorem
ipsum
dolor
sit
amet
</pre>
<pre class="spaceless">
Lorem
ipsum
dolor
sit
amet
</pre>
I have a TWIG code to display the address of a store.
Currently the address is rendered on 3 lines.
How to make the address code on one line ?
{{ store.address|render|trim|replace({'<br>': ' - '})|striptags|raw }}
解决方案
Your are outputting the address inside a <pre>
tag. The white-space
of the <pre>
tag is set to pre
by default. See here for more information about this.
So you have 2 options
- Replace the
<pre>
tag with a<div>
<div>
Lorem
ipsum
dolor
sit
amet
</div>
- Overrule the
white-space
of the<pre>
withcss
pre.spaceless {
white-space: normal;
}
<pre>
Lorem
ipsum
dolor
sit
amet
</pre>
<pre class="spaceless">
Lorem
ipsum
dolor
sit
amet
</pre>
这篇关于如何使用TWIG将地址代码放在一行上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文