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.
Let's say I have a Handlebars page full of HTML and some light logic ({#if}
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 each
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.:
if @isSomeVar?
output += '<p class="something">'
else
output += '<p class="something-else" data-stuff="Some Data">'
output += if @myVar? then @myVar else 'A hardcoded string'
output += '</p><div class="info">'
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 & presentation!
What in the world is my solution here?