By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,722 Members | 1,874 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,722 IT Pros & Developers. It's quick & easy.

Do any of you use a templating engine?

P: n/a
Hi, I was using .net and it uses templates. I like that it did not
mix the UI with logic. I saw there are many templating engines for
php usage. Can you recommend one? I don' t know which to pursue. I
don't need MVC at the moment, but I don't know that the templating
engines require it either.

Thank you.
Sep 9 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
AqD
On Sep 9, 10:28*am, jmDesktop <needin4mat...@gmail.comwrote:
Hi, I was using .net and it uses templates. *I like that it did not
mix the UI with logic. *I saw there are many templating engines for
php usage. *Can you recommend one? *I don' t know which to pursue. *I
don't need MVC at the moment, but I don't know that the templating
engines require it either.

Thank you.
Templating engine isn't needed for MVC. I can't recommand you any pure
templating engines since all PHP ones I know lack simple custom tags
(usually another html file containing place-holders), and their
template syntax(s) don't look any more elegant than php+html.

If you want MVC, try frameworks like symfony or PRADO. Those
frameworks usually come with some sort of templating engines.
Sep 9 '08 #2

P: n/a
On Mon, 08 Sep 2008 19:28:29 -0700, jmDesktop wrote:
Hi, I was using .net and it uses templates. I like that it did not mix
the UI with logic. I saw there are many templating engines for php
usage. Can you recommend one? I don' t know which to pursue. I don't
need MVC at the moment, but I don't know that the templating engines
require it either.
Smarty is by far the best known PHP template engine. However, in my
experience using template engines is cumbersome, inflexible, slow running
and slow to develop. Your templates and your code end up being closely
related anyway and you type your templates in a strange language when PHP
could have done just the same.
Sep 9 '08 #3

P: n/a
jmDesktop wrote:
Hi, I was using .net and it uses templates. I like that it did not
mix the UI with logic. I saw there are many templating engines for
php usage. Can you recommend one? I don' t know which to pursue. I
don't need MVC at the moment, but I don't know that the templating
engines require it either.

Thank you.
http://www.phpguru.org/static/template.html

That's the one I use... simple and blazingly fast. I'm using the old
one not the new one (yet).

--
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-
Sep 9 '08 #4

P: n/a
jmDesktop wrote:
Hi, I was using .net and it uses templates. I like that it did not
mix the UI with logic. I saw there are many templating engines for
php usage. Can you recommend one? I don' t know which to pursue. I
don't need MVC at the moment, but I don't know that the templating
engines require it either.
I've always rolled own out of a couple of regexes.

The tags are just name/value pairs and I make an associative array
($EDIT_TAG) out of them.

If I find a match for something in the library I return the code for
that match, otherwise I do this:

global $CUSTOM;
if((isset($EDIT_TAG['mode']))&&($EDIT_TAG['mode']=='custom')){
if(function_exists($CUSTOM[$EDIT_TAG['name']])){
return $CUSTOM[$EDIT_TAG['name']]($this,$EDIT_TAG);
}
}

I'm a relative newcomer to php, so that's not the best coding.

That's completely flexible. I can read instructions from the tag,
read instructions from the query string, if it's in my CMS, I have the
page path in $this. I can print static pages (which I do for the CMS) or
just spit it back out. I can mix CMS and database output.

I suppose if I had ever gotten through reading someone elses template
engine, I'd use that. But this makes it easy for me to use the same
template for all my needs. If the design changes, I only need to change
the template.

Jeff
>
Thank you.
Sep 9 '08 #5

P: n/a
On Sep 9, 4:28*am, jmDesktop <needin4mat...@gmail.comwrote:
Hi, I was using .net and it uses templates. *I like that it did not
mix the UI with logic. *I saw there are many templating engines for
php usage. *Can you recommend one? *I don' t know which to pursue. *I
don't need MVC at the moment, but I don't know that the templating
engines require it either.

Thank you.
I'm pretty fond of template engines, because even though PHP is one
itself, I hate the syntax of it, especially when you do a lot of
little things throughout a view; nested loops, escaping values,
etcetera quickly make the code a mess.

I used smarty a lot, but it has as many drawbacks as advantages. I
ended up coding my own: http://e.teeselink.nl/mplate - it's a bit like
smarty, but simpler, and most notably allows PHP syntax for function
calls. As such, there's no need to learn yet another new language.
Additionally, there's no real implementation overhead; it's designed
to be nothing but a template engine (= syntactical sugar for your
views) and nothing else, and aims to be easy to plug in to your
current framework/setup/whatever.

</shameless_plug>

Egbert
Sep 11 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.