Template Parser & Associated Questions |
[eluser]Gwarrior[/eluser]
I've been using CodeIgniter for well over a year now and somehow I've managed to never notice the built-in Template Parser class. After taking a look at it, it's like Smarty built-in! So my question is, how many of you swear by it and are there any significant performance drops when using it? Thanks!
[eluser]rogierb[/eluser]
I've used it on some project when it suited my needs. It is rather lightweight. I didn't notice any mentionable performance drops. Even when parsing 40 or 50 pages (A4 size html for printing) it is still fairly fast.
[eluser]Eric Barnes[/eluser]
I personally would love to use it but for me it never suited a project. If it would just include a simple if / else then I would imagine it would get a lot more use.
[eluser]rogierb[/eluser]
I use if/else statements with the parser. <code> if("{some_var}"!="") </code> Works like a charm. And yes, this is php not templating... but hey, it works.
[eluser]Eric Barnes[/eluser]
Very cool. I never thought of doing it that way. ![]()
[eluser]sophistry[/eluser]
"Smarty was a friend of mine. CI Template Parser, you are no Smarty." - WRT, Sen. Althouse don't make the mistake thinking CI Template Parser is like Smarty; it's not. i've used both and now i just use PHP native template style. it's pretty easy - it's even easy to explain. if you use short tags, and you get all of PHP should you need it. with Smarty I was always twisting myself up in smarty-syntax, with the template parser, i was always "prepping" things to get them perfectly arranged in the controller. here's a rundown of "PHP native template" (copied from this old post http://ellislab.com/forums/viewthread/102566/#517530: ------------------------------- just turn on short tags and tell the client you found a good template parser. i wrote the documentation for you below. :-) the syntax is very simple (and supports what you want - if and foreach)): <? to start template tag, ?> to end template tag, to display template variable use echo keyword, example: <? echo $variable ?> <? if($variable_to_test): ?> to start conditional, <? endif; ?> to end conditional, example: <? if($is_true): ?> <? foreach($list as $item): ?> to start loop, <? echo $item ?> inside loop <? endforeach; ?> to end loop in the controller...(developer will edit this) Code: function template() Code: <html> EDIT: you could even do it with short tags Code: <html> |
Welcome Guest, Not a member yet? Register Sign In |