I'm building a web app that relies fairly heavily on Ajax for its interactivity, and I want to get around the problem of having two versions of my HTML templates, to keep things DRY.
I came across a question here, template engine both for JS and PHP, which came up with a good answer, mustache. Then I remembered all the stuff I wouldn't be able to do, like Zend_View_Helpers, and other PHP reliant stuff.
My question is, are there any better solutions? Perhaps that would allow me to use Zend_View (or similar to output to a templating language), which would allow me the flexibility of PHP and its libraries, but the DRYness of a template language.
That, or another solution entirely that I haven't thought of. I'm sure this sort of thing has been done many times before, so are there any best practices (or bad ones).
Thanks
Whilst I am not entirely sure what you are attempting to do how about using the Twig project. You can pass objects into the template and access its properties and methods:
There is also a JS port of the Twig templating language.