Jump to content

Any tutorials of template engines?


GuitarGod

Recommended Posts

Hi all,

 

I was just wondering if anyone knew of any good tutorials on creating your own template engine? Mostly just to seperate PHP from HTML, also to use for blocks:

 

if ( CONDITION )
{
    $template->block( NAME ) // you get the picture 
}

 

I know there are lots of free template engines out there I could use, but for this project I really think I should create my own, nothing too fancy, just to do the basics.

 

Thanks ;D

Link to comment
https://forums.phpfreaks.com/topic/148294-any-tutorials-of-template-engines/
Share on other sites

I can see your point and have often thought about mixing the basic HTML with PHP, but this is a commercial project so I thought it best to have the code as "professional" as possible, and people tend to frown upcode mixed PHP/HTML. But your method is definitley worth consideration, thanks ;D

Templating is really just DOM element iteration and tag replacement.  If you make a DOM based templating system that mimics the behavior of a library like jquery, you minimize the need for frontend guys to learn a new syntax.

 

I'd recommend reading up on the DOM libraries, specifically DOM and SimpleXML, and go with a DOM based templating engine. 

 

I know this isn't the most processor efficient code, but in terms of project maintainability, it's a heck of a lot easier to find a good XHTML/JS coder than a good XHTML/JS/PHP coder.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.