0

Based on the following docs, I can easily make use of the If Expressions as exampled. But how can we take them further by wrapping HTML to the object? I want to do something like this...

{{ "<li>" . foo . "</li>" if foo else '' }}

what would be the proper syntax?

klewis
  • 7,459
  • 15
  • 58
  • 102

1 Answers1

0

As I have recently discovered, one way to go about this process is to use the Join and Safe filters to help achieve this goal. The following works for me today.


  {% set desc = ["<li class='m-y-sm'>", event.description, "</li>" ] | join | safe %}

  <ul>
    <li><p>guaranteed content</p></li>
    {{ desc if event.description else ''}}
  </ul>

klewis
  • 7,459
  • 15
  • 58
  • 102