Question:
Will adding a templating engine such as Mustache, which has been converted into many different languages, assist in doing the same for a web application?
Background:
I am in the process of finishing up a product that will be reused many different times. Right now I have the back-end programmed in php. I was wondering if mustache.php or mustache.js would be beneficial to add to the web application, without reducing the performance noticeably. I was planning on making it easier to convert to JSP/Servlets, and ASP.NET/C#. Right now the variables that are set by the user such as logo, and Company name are sprinkled throughout the pages.
Choosing any templating language will be beneficial to your application. It will help you compartmentalize logic, improve the testability of your code (and your output), and, by constraining what you can do in any given layer, help you write objectively better code.
So yes, by all means, use a templating language.
Is Mustache(.php|.js) the right templating language to use? In my humble opinion (as a guy who wrote one of the two libraries in question) they are a very solid choice. The portability between implementations plays a big part in this, but there are a lot of other not-so-obvious benefits of Mustache.
@kneath wrote a blog post worth reading on the matter. You should check it out.
And to answer your implied-but-not-asked question, you won’t be sacrificing performance. Mustache.php is quite fast. You’ll hardly notice the difference 🙂