Jump to content

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.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.