473,403 Members | 2,183 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Do any of you use a templating engine?

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
5 2309
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Roger Jack | last post by:
I have just finished reading Code Generation In Action which uses Ruby for code generation. I would like to use Python instead. Is Cheetah the best tool to use for templating source code files and...
31
by: Leif K-Brooks | last post by:
I'm planning to start on a fairly large web application, most likely using mod_python. I recently wrote a fairly small (but real-world useful) web app with it, and all of those req.write()s made...
4
by: Przemyslaw Wegrzyn | last post by:
Hi ! Does anybody know any good, open-source library similar to Perl's Template or Jakarta Velocity ? Best Regards, Przemyslaw
18
by: pkassianidis | last post by:
Hello everybody, I am in the process of writing my very first web application in Python, and I need a way to generate dynamic HTML pages with data from a database. I have to say I am...
7
by: Paul | last post by:
I have been coding apps with PHP for several years. But I am getting more involved in larger and more complicated PHP applications and want to use best practices. I use Eclipse's PHP IDE. I...
10
by: Terrence Brannon | last post by:
Hello, The most common way of dynamically producing HTML is via template engines like genshi, cheetah, makotemplates, etc. These engines are 'inline' --- they intersperse programming...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.