wrap new line variable with
  • 2019-08-23 18:12发布

    问题:

    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>