3 Reasons to choose Logic Less templates like Mustache
Templating systems come in many tastes and sizes. However, the first distinction that a user needs to make is whether to allow logic in templates or not. Templating engines range from almost no logic to a fair amount of logic. As a startup, we have learnt after making mistakes that no logic in templates is the best logic. Here is why:
1. Let there be no logic
If engineers can introduce logic anywhere - they will introduce logic there. However, if they can't test it easily. For instance with templates, usually the way to test template logic is to check for substrings in an ever growing template with different context dictionaries. However, this may or may not be easy (further depending on whether the templating engine allows modularization, template function etc.) and it may lead to a significant amount of business logic residing in templates without any testing. Needless to say this is like watering a tree of bugs. So unless you can ensure test coverage, try not to introduce logic in your templates.
2. Confinement of logic
Logic less templates force you to write your business logic in your app. So the data sources, directory structure and test suites remain common. Isn't that wonderful. Forcing your code to reside in your app, forces a certain level of test ability. Aren't you convinced ?
3. Think when its time to think and render when its time to render
Of course, this entirely depends on how you write your app's code and how your templating engine works. However, logic less templates make it much easier for you to improve on bottlenecks and pass the reign of performance to your app. This allows you to set SLAs on your server response time.
Okay, I understand in interest of speed you may not want logic less templates. But do keep that in mind and whenever you see your app's bugs coming once too often from template land switch as soon as possible. Mustache has worked well for us so far and with Hogan compiling is pretty fast too.
Wishing you luck.