Jump to content


Photo

Perfect templating system?


  • Please log in to reply
5 replies to this topic

#1 devbanana

devbanana
  • Members
  • PipPip
  • Member
  • 18 posts
  • LocationI don't know, but all I can see is this computer...

Posted 26 August 2006 - 11:27 AM

What, in your opinion, would the perfect templating system be like? I'm not looking for systems that have been already made, but features that you would want to see in a good templating system. Please be realistic. :)

I know some people just like to have PHP intermingled with HTML, such as:

Hello <?php echo $user?>.

But I don't really like this. It would be too tempting to do some processing in the presentation layer that does not belong in the presentation layer, plus I think it is too messy, as far as syntax is concerned.

I'm thinking of, perhaps, a declarative syntax, that would mostly look like regular HTML, but would be parsed by the template system and replaced.
Programming in PHP since 1882. Oh wait, computers weren't around that long, huh....
Hey, while we're here, would you mind giving me some suggestions on my PHP framework?

#2 devbanana

devbanana
  • Members
  • PipPip
  • Member
  • 18 posts
  • LocationI don't know, but all I can see is this computer...

Posted 27 August 2006 - 07:15 PM

Great to see this is generating such an enthusiastic response. ::)

Well, in spite the fear of talking to myself...

I have been checking out XSLT, and it seems like it'd be a very nice tool to use for templating. A bit complicated, but at least it is a standard, and it can output various formats, so it doesn't necessarily need to be bound to outputting HTML/XHTML.
Programming in PHP since 1882. Oh wait, computers weren't around that long, huh....
Hey, while we're here, would you mind giving me some suggestions on my PHP framework?

#3 steelmanronald06

steelmanronald06
  • Staff Alumni
  • Advanced Member
  • 2,004 posts
  • LocationOk

Posted 28 August 2006 - 12:40 PM

SMARTY

#4 devbanana

devbanana
  • Members
  • PipPip
  • Member
  • 18 posts
  • LocationI don't know, but all I can see is this computer...

Posted 28 August 2006 - 12:52 PM

SMARTY


Hi,

Thanks for the reply. However, as I mentioned in my first post, I'm not looking for existing templating systems, but what features you would look for in a templating system.

I don't like Smarty, because the logic is too imparative. If you're going to use Smarty, you may as well just use PHP for presentation logic, because they're both just as imparative.
Programming in PHP since 1882. Oh wait, computers weren't around that long, huh....
Hey, while we're here, would you mind giving me some suggestions on my PHP framework?

#5 steelmanronald06

steelmanronald06
  • Staff Alumni
  • Advanced Member
  • 2,004 posts
  • LocationOk

Posted 28 August 2006 - 04:43 PM

Honestly, I can't really say. I create my own template systems for each project I do.  That way I have a system that is unique and custom to each project.

#6 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 01 September 2006 - 02:51 PM

off the back of this article:

http://www.massassi....mplate_engines/

i created my own. the problem with templating engines is, whilst they offer plenty of other features, they're just ultimately a new set of syntax. people take the "seperation" a bit too far, when the actual idea is just to seperate your "business" logic from your "presentation" logic. no matter how hard you try, its not really possible to remove ALL of your code from the HTML - no matter how you dress it up, re-syntax it, etc.

ok, so some people don't like using php short tags. but if they do, is typing <?=$name; ?> really that much harder than {name} ? and many of these 'Engine' templates also use similar methods for looping, whereas the 'foreach' in PHP is simple enough in itself, without the need to replace it with a new set of syntax.

in terms of what i look for - just something lightweight and simple that keeps the bus/pres logic as seperate as possible. i literally have 3 main functions in my template class other than the constructor:
1. function to set a variable
2. function to load a (sub)template to a variable
3. function to output

seriously, the link i posted above is definitely an excellent read which, in itself, covers most of your queries.

hope that helps a bit
Cheers
Mark
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users