Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 494
Florian Avatar asked May 14 '11 18:05

Florian


People also ask

Is PHP a template engine?

PHP is not a template engine, but a language that can be used to write templates, or template engines. A template engine is not just a language, but also the programming API that allows the scripts to locate, organize templates or assign the data from the script to them.

Should I use a template engine or react?

At the moment, when we decide to implement some interactions, react-engine will be the winner. While react-engine rendering does not require JavaScript to run on the client side, it will enable SEO over the search. Template engines also have this SEO support, but with less impact.


1 Answers

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/
like image 50
mPrinC Avatar answered Sep 29 '22 14:09

mPrinC