问题
We are using WHMCS and within the product section I want to wrap the product with <li></li>
on every new line. So far I have done the following, which gets me all the items but puts them all in one line, but I haven't been able to work out how to assign these stripped values to a new var to be wrapped with the list tag.
{foreach from=$product.features key=feature item=value}
{$value|strip_tags}
{foreachelse}
{$product.description|strip_tags}
{/foreach}
回答1:
You can use the following code:
{assign var=lines value="\n"|explode:$product.description|strip_tags}
<ul>
{foreach key=k item=line from=$lines}
<li>{$line}</li>
{/foreach}
</ul>
来源:https://stackoverflow.com/questions/30259445/wrap-new-line-variable-with-li