Author Topic: My experience with vLib.Template  (Read 2267 times)

0 Members and 1 Guest are viewing this topic.

Anton

  • Guest
My experience with vLib.Template
on: Tue, 25. November 2003 - 19:57:00
Hello all!

I just finished with my project   http://www.conauction.com
This site made only with vLib.Template.
I want to tell to all persons who consider to use vLib.Template in their projects: use it! It's really great stuff. You have in result easy to support PHP and HTML files. Time on developing/rebuilding/changing templates really short. Time on digging into library also small - everything explained in docs. You just start to program and nothing more. I found just one big problem with vLib: grab() returns empty string, but thanks to this forum I got rules to fix problem at the day I spot the problem.

Maybe template language not so flexible and expressive as we want. Maybe it'll be wise to implement complex logical expressions with ADD/OR/NOT/XOR and several TMPL_VAR values. Maybe it'll be wise to add switch-case constructions to the language. But I made all these things using standard set of vLib.Template commands and still alive  :)

Telling truth I do not have speed/load results on my site yet and do not know how vLib will run on the highest (practically impossible)  pressure. But other guys made speed/load tests as far as I know and results force me to look optimistic on increasing of the loading.

releasedj

  • Guest
My experience with vLib.Template
Reply #1 on: Wed, 26. November 2003 - 12:45:27
Thanks for the feedback. It's always great to get feedback whether good or bad.

To use vlibTemplate in the most optimized way possible use vlibTemplateCache upon instantiation, i.e.:

Code: [Select]

$tmpl = new vlibTemplateCache'mytemplate.html';



This will greatly increase the time taken to display pages as the compiled templates are saved and used for subsequent accesses.

With regards to your problem with vlibTemplate::grab(), this should be fixed with the most recent release @ http://prdownloads.sourceforge.net/vlib/vL...-2.zip?download

Thanks again for the feedback.

Regards,

Kelvin

Offline ClausVB

  • Administrator
  • Hero Member
  • *****
  • Posts: 566
    • Homepage: clausvb.de
My experience with vLib.Template
Reply #2 on: Thu, 27. November 2003 - 23:06:30
My 2 cents:

I never was in need for "ADD/OR/NOT/XOR", so I would suggest not to program it.

Switch-Case could be quite useful sometimes, but I had never any trouble to program it with PHP Switch-Case and then using "setVar" to parse the content.

Regards,
Claus

Anton

  • Guest
My experience with vLib.Template
Reply #3 on: Wed, 03. December 2003 - 18:47:11
Quote
Thanks for the feedback. It's always great to get feedback whether good or bad.

To use vlibTemplate in the most optimized way possible use vlibTemplateCache upon instantiation, i.e.:

Code: [Select]
[!--QuoteEBegin--][!--QuoteEBegin--]$tmpl = new vlibTemplateCache'mytemplate.html';[!--QuoteEBegin--][!--QuoteEBegin--]


This is what i made on my site already.
Caching is working and caching is cool thing in vLib.Template.
I made indexing on my MySQL tables and data accessing become faster.
Of course I'll optimize code in future.

Anton

  • Guest
My experience with vLib.Template
Reply #4 on: Wed, 03. December 2003 - 18:59:13
Quote
My 2 cents:

I never was in need for \"ADD/OR/NOT/XOR\", so I would suggest not to program it.

Switch-Case could be quite useful sometimes, but I had never any trouble to program it with PHP Switch-Case and then using \"setVar\" to parse the content.

Regards,
Claus



I am talking about clearness and pretty style of code inside HTML templates.
Imagine such constructions:

1. Imagine that you have 3 TMPL VARS: v1, v2 and v3.
They all have some values.
And imagine such piece of HTML template:

<TMPL_LOGIC VALUE="v1 AND (v2 OR v3)">
here we place something to do when "v1 AND (v2 OR v3)" is true
</TMPL_LOGIC>

Is this expressive thing or not?

2. Imagine that you have TMPL_VAR c and such code:
<TMPL_SWITCH NAME='c'>
<TMPL_CASE VALUE='1'>
here we place something to do when c = 1
<TMPL_CASE VALUE='2'>
here we place something to do when c = 2
<TMPL_CASE VALUE='3'>
here we place something to do when c = 3
<TMPL_CASE VALUE=DEFAULT>
here we place something to do when c != 1 and c != 2 and c!= 3
</TMPL_SWITCH>

I suppose (maybe I am wrong, kill me in this case  :)  ) that such code really easy to write, read, understand and update. Can I make such things without expanding vLib.Template language?

releasedj

  • Guest
My experience with vLib.Template
Reply #5 on: Thu, 04. December 2003 - 12:00:19
I think a sound peice of advise would be to try and keep as much logic on the PHP side of things.

If you mix the application logic with the design logic you start creating unmaintainable code. You have to start looking in both the php script and the template to see what the application is doing.

I was even reluctant in putting the op attribute in because that was putting application style logic in the template and it's something that I'll never use.

IOn my opinion it would be much better doing the following:

Code: [Select]

?php

// ... code



// for the logic

if $var1 && $var2 or $var3



    $tmpl-setVar'show_something1', true;





// for the switch

$tmpl-setVar'c_'.$c, true; // this gives you a variable c_1 or c_2 for example



// ... code

?





In your template



!-- logic --

tmpl_if name=show_something1

Do whatever here....

/tmpl_if



!-- switch --

tmpl_if name=c_1

  show stuff for c = 1

tmpl_elseif name=c_2/

  show stuff for c = 2

tmpl_elseif name=c_3/

  show stuff for c = 3

tmpl_else /

Default stuff

/tmpl_if



This is just as neat in my opinion and keeps just the display logic in the template.

Regards,

Kelvin

Offline ClausVB

  • Administrator
  • Hero Member
  • *****
  • Posts: 566
    • Homepage: clausvb.de
My experience with vLib.Template
Reply #6 on: Fri, 05. December 2003 - 10:48:57
I totally agree.

You could even do the whole job in PHP if it's just a little text you want to display like:

Logic (if, switch and so on)
$switch_tmpl_var = 'show stuff for c = 1';
or
$switch_tmpl_var = 'show stuff for c = 1';
or ...
end logic


$tmpl->setVar('switch_tmpl_var', $switch_tmpl_var);

I did it that way for a very complex switch-case structure. Works like charm.