<div class="center" id="headings">
  {each $heading => $headingVar in ['h1' => 'h1_title', 'h2' => 'h2_title', 'h3' => 'h3_title', 'h4' => 'h4_title']}
    {if !empty($$headingVar)}
      <{heading}>{% $$headingVar %}</{heading}>
    {/if}
  {/each}
</div>

<div class="center" id="headings">
  {each $heading => $headingVar in ['h1' => 'h1_title', 'h2' => 'h2_title', 'h3' => 'h3_title', 'h4' => 'h4_title']}

    {* Two dollar signs to take the variable value and treat it as the variable name.
       http://php.net/manual/en/language.variables.variable.php *}
    {if !empty($$headingVar)}
      <{heading}>{% $$headingVar %}</{heading}>
    {/if}
  {/each}
</div>

Add TPL comment saying it isn't a typo there is 2 dollar signs
Add TPL comment saying it isn't a typo there is 2 dollar signs

To avoid having it removed by another dev thinking that it's a mistake.
