Forums / Cotonti / Development / Twig: modern template language

<<<12

urlkiller
#16 2010-09-11 01:44
so if i understand this correct that cotemplate thing will give us more blocks in the existing templates or does it mean that we have to rebuild all templates/plugins that uses tpls (more or less) ?
URL shortener: <a href="http://bbm.li/!7AD5C7">http://bbm.li/!7AD5C7</a>
ez
#17 2010-09-11 01:46
This all looks very promising... (and Cotonti has the first hybrid !!!!)

I hope there will be some good documentation about all new/all features.
I want to know everything :)

thnx T, and the rest for all these good ideas
==- I say: Keep it EZ -==
Trustmaster
#18 2010-09-11 04:27
Well, you don't have to rebuild anything and it acts pretty same way as before except for a few things:
  1. You can put logical IF/ELSE/ENDIF blocks inside of other logical blocks. And normal BEGIN/END blocks inside of logical blocks. And combine them how you want.
  2. You can pass template variables through PHP functions using callbacks a.k.a. extensions or pipes. Just like this: {FORUMS_TOPIC_TITLE|str_replace('Twig', 'FooBar', $this)|stripslashes}.

Other details are more technical, like a better template compiler which eliminates any parsing at render-time. I think nobody here truly realizes what he'd need nested logical/begin-end blocks for. I just made a different architecture which makes it possible.
May the Source be with you!
GHengeveld
#19 2010-09-13 16:14
Did you do any performance testing? I've got one site running so many conditional blocks that I'm running against the limit. If I include one more IF block it just stops working.
FYI I'm using a TagFactory class which loops over a multidimensional array and assigns tags and parses blocks. That's why there's so many.
Trustmaster
#20 2010-09-13 21:12
I did benchmarks on sed-light/genoa and nemesis/trunk, apart from the particular feature tests. But it has been recently reported that at some tpls it fails to render correctly. Tpl files to test on would be appreciated for fixing bugs.

BTW, I still do not recommend using too much of IF logics where traditional blocks can be used. Blocks are better structured and controlled from PHP code, they are still faster than conditionals too. For people who want IF blocks alone, I'd recommend using PHP as template engine itself.
May the Source be with you!
GHengeveld
#21 2010-09-15 01:38
Well, as long as the client isn't requesting any more weirdness (having a meeting with him tonight), all will be fine. I'm likely going to implement an html caching mechanism to make it all even faster (this particular project doesn't use Cotonti, just the XTemplate class from Cotonti).
Trustmaster
#22 2010-09-15 02:09
Make sure you have global $cfg['xtpl_cache'] = true and the appropriate cache folder. Without this, Co/Xtemplate performance can be really poor.
May the Source be with you!

<<<12