Which templating engine can I use with both JS and PHP?

Florian picture Florian · May 14, 2011 · Viewed 14.6k times · Source

I'm looking for a simple Template engine that works both on client side with JS ánd on server side with PHP.

That means I want to be able to use the same template definition for both use cases.

Do you know any templating engines that have official implementations in both JS and PHP?

Answer

mPrinC picture mPrinC · May 20, 2011

If you like JS->PHP priority :) then you have this two jquery-tmpl compatible template renderer for PHP backend

  1. https://github.com/abackstrom/jquery-tmpl-php
  2. https://github.com/xyu/jquery-tmpl-php

If you prefer more PHP->JS priority :) then you can try this Javascript implementation of popular PHP templating Smarty

  1. http://code.google.com/p/jsmart/

Or you can try something more neutral like:

  1. Mustache http://mustache.github.com/