# Help with twig syntax

**URL:** https://forum.mautic.org/t/help-with-twig-syntax/3496
**Category:** Product Support
**Created:** [April 12, 2016, 12:42pm UTC](https://forum.mautic.org/t/help-with-twig-syntax/3496 "2016-04-12T12:42:38Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![lwdeddie](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/lwdeddie/32/755_2.png) [@lwdeddie](https://forum.mautic.org/u/lwdeddie)
#### Post date: [April 12, 2016, 12:42pm UTC](https://forum.mautic.org/t/help-with-twig-syntax/3496/1 "2016-04-12T12:42:38Z")

</div>

Hi, I’d like to use the twig engine in our custom emails. Specifically, where a slot has no content that slot and its corresponding area (

, , , etc.) should not display as an empty space. Empty template areas are unattractive and I’d like to place a conditional on a ALL my slots for layout attractiveness and flexibility.  
  
  
  
I’m sure this is incorrect. Can somebody please assist with the proper syntax to do this please?  

Code:

{% if slots:content is not empty %} 

| \<?php $view['slots']-\>output('content'); ?\> |

{% endif %}

---

<div class="post-metadata">

### Author: ![lwdeddie](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/lwdeddie/32/755_2.png) [@lwdeddie](https://forum.mautic.org/u/lwdeddie)
#### Post date: [April 12, 2016, 12:42pm UTC](https://forum.mautic.org/t/help-with-twig-syntax/3496/2 "2016-04-12T12:42:38Z")

</div>

Hi, I’d like to use the twig engine in our custom emails. Specifically, where a slot has no content that slot and its corresponding area (

, , , etc.) should not display as an empty space. Empty template areas are unattractive and I’d like to place a conditional on a ALL my slots for layout attractiveness and flexibility.

I’m sure this is incorrect. Can somebody please assist with the proper syntax to do this please?

`{% if slots:content is not empty %}
	<table><tr><td>
                 <?php $view['slots']->output('content'); ?>
	</table></tr></td>
{% endif %}`

---

<div class="post-metadata">

### Author: ![lwdeddie](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/lwdeddie/32/755_2.png) [@lwdeddie](https://forum.mautic.org/u/lwdeddie)
#### Post date: [April 12, 2016, 3:30pm UTC](https://forum.mautic.org/t/help-with-twig-syntax/3496/3 "2016-04-12T15:30:27Z")

</div>

No sorry I didn’t but that page link is very helpful. I’m beginning to understand it better. Thank you.

Question, what are the ‘page\_title’, ‘top1\_title’ elements? Is this an array referencing other slot titles? If so, can I do this:

[code]{% if slotHasContent([‘top1’]) %}

{{ slot('top1') }}
{% endif %}[/code]

If not what do they actually reference?

Forgive me in advance for being a script-kitty and not a full programmer.

---

<div class="post-metadata">

### Author: ![lwdeddie](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/lwdeddie/32/755_2.png) [@lwdeddie](https://forum.mautic.org/u/lwdeddie)
#### Post date: [April 12, 2016, 6:54pm UTC](https://forum.mautic.org/t/help-with-twig-syntax/3496/4 "2016-04-12T18:54:49Z")

</div>

Thanks. I’ll give it a try.

---

<div class="post-metadata">

### Author: ![lwdeddie](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/lwdeddie/32/755_2.png) [@lwdeddie](https://forum.mautic.org/u/lwdeddie)
#### Post date: [April 13, 2016, 12:03pm UTC](https://forum.mautic.org/t/help-with-twig-syntax/3496/5 "2016-04-13T12:03:39Z")

</div>

No I’m sorry to say this code doesn’t work. It displays as text in the delivered email. I’m running Mautic 1.3.1. Is there something else I should have included/activated for this code to process? It looks like it’s not processing.

`{% if slotHasContent(['sub-title']) %}
                 <!--slogan-->
                     <tr>
                     <td align="center" style="font-family: 'Open Sans', Arial, sans-serif; color:#898989; font-size:12px;line-height: 28px; font-style:italic;"><?php $view['slots']->output('sub-title'); ?></td>
                     </tr>
                 <!--end slogan-->
           {% endif %}`
