title: Conditional Attributes in Sightly Templates (AEM/CQ)
body: <p>In the Sightly templating language, for Adobe AEM6 (CQ), how do I add an attribute to an element only if a condition is true, without duplicating lots of code/logic?</p>
  
  <p>e.g.</p>
  
  <pre><code>&lt;ul data-sly-list="${items}" ${if condition1} class="selected"${/if}&gt;
      &lt;li${if condition2} class="selected"${/if}&gt;
          Lots of other code here
      &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>