template engine: twig, dwoo, smarty or CI parser?

#1
[eluser]introvert[/eluser]
Hello,

I've come to a big dilemma with making decision which template engine to choose for my CI project.

I'm deciding between:
- twig
- dwoo
- smarty
- CI parse

I've read somewhere that I should avoid smarty because its slow (that was for version 2.0), how is version 3.0? The speed tests for new version say different story.

What about twig and dwoo?

What is your experience? What would you choose and why?

I have to be able to have embedded templates, variables, etc.

Thanks a lot for help

#2
[eluser]Davide Bellini[/eluser]
Hi guy!
I tried to use Smarty 3, Dwoo and Twig in my current project to test flexibility, speed and power of template engine.

- CI Parser is very fast but doesn't support template inheritance, modifiers, sandbox, ... ( is very basilar parser )
- Dwoo and Smarty are very similar ... Smarty has a better documentation and a big community, but no sandboxing
- Personally Twig is my favourite ... Is fast, secure, flexible and have good documentation.

Finally, I can't say that Twig is better than Smarty, depend by your needs ... But I can suggest you to use Smarty or Twig ( check documentation for this 2 project and follow your instinct ) Tongue

Cheers

#3
[eluser]Eric Barnes[/eluser]
Check out dans tags - https://github.com/dhorrigan/ci-spark-tags

Not as powerful as smarty but has lots of cool options. Currently pyrocms uses this, if you want to see it in use.

#4
[eluser]mohrt[/eluser]
[quote author="Davide Bellini" date="1300251137"]Smarty has a better documentation and a big community, but no sandboxing[/quote]

Just an FYI, you can control quite a bit of what is exposed to the templates with security features of Smarty.

security docs

#5
[eluser]John Nickell[/eluser]
I've been working on a pure PHP template library, since I have been unable to find an OO template class that includes template inheritance.

I've tried Smarty and Twig, and I like both of them, but I was hoping for "lighter" solution. My ideal class would allow:

1. Partial and nested views
2. Overriding default templates with more-specific templates
3. Template inheritance (more-specific template can extend the default)

The "pure" PHP solutions out there either don't offer template inheritance, or use global variables instead of class variables for the stored data.

Is there anyone else that is looking for a similar solution, that has maybe found it?

If anyone is interested, I might create a GitHub repository with the one I'm working on, but I am an admittedly inexperienced coder.

So far it has a syntax that looks like this:

<?php $this->extend(‘default.tpl.php&rsquoWink; ?>

<?php $this->block(‘content&rsquoWink; ?>
<p>extended content that replaces base template block</p>
<?php $this->endblock(); ?>

<?php $this->endextend(); ?>

Of course, if you wanted to replace the entire default template, you would just follow some naming convention to create the more-specific template...then do not extend the base template. So you can replace the entire template, or blocks, and you do that on a full-view or partial-view level.

#6
[eluser]Aken[/eluser]
I use Smarty on my website. Granted I haven't tried any other ones (I probably will now), it works pretty well. I haven't noticed any terrible speed issues (I use CI's caching on top of it, so once cached it's super fast regardless). It does seem a bit bloated for what I use it for, but it works, and my site isn't heavily trafficked at all, so whatever.

I have some code on GitHub for basic implementation of Smarty into CI: https://github.com/cryode/CodeIgniter_Smarty

#7
[eluser]Ed Robindon[/eluser]
I have used Smarty for several years now. The speed issue seems to be a red herring. Smarty compiles your template only when it changes leaving php files not unlike a lot of other php as template engine pages.

I am new to CI and have already integrated Smarty 3.x and xajax 0.6 and my application really sings.



Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.