/
Optimizing templates for AJAX

Optimizing templates for AJAX

Imported From: http://groups.google.com/group/in-portal-dev/browse_thread/thread/d617b8d69e52e435#

Hello colleagues.
In today projects we use Ajax a lot. Usually page contains more than
just a one block of dynamic content. For example - sidebar with "my
friends", "currently online", "group users" blocks and so on.
Each of that boxes requires separate file to be created (because you
need to get some specific content by one HTTP request to this separate
file).
I was thinking about making things easier and now i want to hear your
thoughts on this:
What if we could request only /specific/ /part/ of the template by
passing some variables along with request?
For example, template test.tpl:
--------------------------------------
some code here
<!-- section:sample1 -->
code for dynamics
<!-- endsection:sample1 -->
some code here
--------------------------------------

When we go to the localhost/test.html we see page as usually, no
changes. But when our dynamic block needs to be updated, Ajax request
sends that section name to the same page:
localhost/test.html?some_Page=2&section=sample1
And now parser only processes code, that is located between <!--
section:sample1 --> and <!-- endsection:sample1 --> tags.
In this way we are no more forced to create countless templates for each
separate block.

What you think about this?