title: How to truly separate template from code?
body: <p>I have a conundrum here, and I apologize for not being able to just copy and paste code as it's internal corporate stuff. I'll try to explain the best I can without showing code.</p>
  
  <p>Let's say I have a Handlebars page full of HTML and some light logic (<code>{#if}</code> statements). The thing is, there are a LOT of if/else/etc statements interspersed between HTML bits. This is probably fine except for the fact that within an <code>each</code> loop, I now have to introduce some logic that is beyond what Handlebars will allow (basically I need to check the index of the current iteration of the loop [if index > 4 then..]). So now I have to code my logic into a Handlebars helper, but I also have to bring all the HTML into the helper code now! e.g.:</p>
  
  <pre><code>if @isSomeVar?
    output += '&lt;p class="something"&gt;'
  else
    output += '&lt;p class="something-else" data-stuff="Some Data"&gt;'
  
  output += if @myVar? then @myVar else 'A hardcoded string'
  output += '&lt;/p&gt;&lt;div class="info"&gt;'
  </code></pre>
  
  <p>So because Handlebars is logicless because it wants to remain clean, I have to move HTML into my .coffee code, which kinda defeats the whole purpose of separating code &amp; presentation!</p>
  
  <p>What in the world is my solution here?</p>