Handlebars Just Adds Bloat and Complication

By Forrest Smith - Drempd.com

I kind of like Handlebars for templating, but more and more, I think it’s just makes the codebase more bloated and complicated:

My problems with handlebars:

1. I can’t just use my existing javascript code. For instance, I have an existing function to format a phone number, but to use this within a handlebars template,  I have to write a “Helper” to utlilize the function code (which basically just wraps my existing function). This is extra code that shouldn’t really be necessary, adding to the code base, adding a layer of complication, and requiring extra time to build and maintain.

2. Functionlity is limited. I know it’s by design, but I want to be able to write more complex if statements, switch statements, etc.. I can write helpers for this purpose, but then I am just basically rebuilding functionality that already exists within javascript. This adds additional unnecessary code and additional things to maintain. I used the comparison helper from this site (http://doginthehat.com.au/2012/02/comparison-block-helper-for-handlebars-templates/) for a project.  It’s a helpful piece of code, but this functionality already exists with straight javascript.  I then wanted to make more complex statements (like “if (x==1 || x== 33), which would require additional work on adding functionality to the helper. Without the ability to use things like the “or” statemtent above, I have to write more handlebars code (separate if statements), which just adds more code to the site that isn’t necessary.