Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Server side templates, client side templates - Automatic conversion?

With the event of the jQuery templates plugin, I am wondering how to maintain both server-side and client-side templates.

Because in my case, I have some templates, that would be duplicates - server-side as well as client-side. Just imagine this:

You have a form, where you can enter list points. When you press submit, an AJAX request is generated but the entry is already showed on your page.

Now, the markup for this bullet point should be the same - wether it was generated through JS or by my PHP/.NET/whatsoever application.

Are there any good ways to maintain those templates / keep them in sync? Or do I really have to manually maintain both templates?

What is your experience in applications using JS templates?

like image 560
Sebastian Hoitz Avatar asked Dec 19 '10 22:12

Sebastian Hoitz


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 184
mPrinC Avatar answered Oct 21 '22 15:10

mPrinC