Please help support Savant; you can donate, or click on a sponsor.
|
Savant2 (2.4.3)
Savant is a powerful but lightweight object-oriented template system for PHP.
Unlike other template systems, Savant by default does not compile your templates into PHP; instead, it uses PHP itself as its template language so you don't need to learn a new markup system.
Savant has an object-oriented system of template plugins and output filters so you can add to its behavior quickly and easily.
Savant has an extensible error handling system. While Savant uses its own minimalist error class out-of-the-box, it supports PEAR_Error and PEAR_ErrorStack, as well as PHP5 exceptions. You can also add your own error classes to support your favorite framework error system. Error-handling hooks are provided in the standard Savant class.
Even though Savant does not come with one, you can write your own customized markup compiler and hook it into Savant. This means you can invent any markup system you like; as long as your compiler turns it into a PHP script, Savant will be able to use it. As with the error handler, you don't need to extend Savant itself to do this; compiler hooks are provided in the standard Savant class.
Savant is streams-aware and can use any stream as a template source.
PHP4 and PHP5
Savant is written for PHP4 and runs without warnings or notices under E_ALL.
Savant works out of the box with PHP5, but does not yet adhere to E_STRICT. If you require E_STRICT compliance, please try version 3 of Savant.
Why Not Compile Templates?
Please see these comments and explanation from Harry Fuecks and Brian Lozier.
In short, PHP is itself a template language, so in general there is no need for another template language on top of it. However, there are some specific cases where using customized markup is safer than PHP; for that reason, Savant allows you to hook in a custom compiler for your own purposes.
Why Use Savant for Templates?
Among other reasons...
- You don't need to learn a new language or markup to create a template. The template language is PHP, and the template file is a regular PHP file.
- You don't have to worry about separate directories (or permissions on those directories) for compiled template sources, because Savant is not a compiling engine (the template scripts are already written in PHP).
- Even though Savant is not itself a compiling system, you can write your own compiler and plug it into Savant; this means you can use any template markup system you like.
- The Savant source code is easy to read, understand, and extend, because it is exceptionally well-commented.
- The object-oriented plugin, filter, error, and compiler classes for Savant are easy to use, understand, and extend.
- Because your template script is a regular PHP script, you can sprinkle it with comments and use phpDocumentor to document it.
This site powered by YaWiki 0.22 beta.
Copyright © 2003-2009, Paul M. Jones.
pmjones [AT] ciaweb [DOT] net
2006-09-06 18:12:45 (1180)
Hi szbeam --
Your disdain and condescension toward designers is duly noted.
Personally, I've never had trouble from designers using PHP (i.e., when
they needed to work in HTML, and not in CSS).
When you say, "But you should have a strict system for separating logic
and layout" I can only half-agree, because I think you misapprehend the
issue.
It's a common argument that one should separate all logic from all
presentation (the "keep PHP and HTML separate" cliche). I would say the
issue is more about keeping business-logic tasks separate from
presentation-logic.
Unless you are using a transformation engine of some sort (e.g. XSLT), I
don't think you can entirely avoid presentation logic in views; the one
exception I can think of would be something like echo-only views.
Smarty provides a way to perform presentation logic by using a new markup.
Savant provides presentation-logic tools without introducing a new
language or markup system for templates. I think using Savant is easier
for developers, since they already know PHP, and I think it's no harder on
designers than it is to learn Smarty markup. You may think otherwise.
If you would like to continue this discussion, I'd be eager to so via a
more powerful and responsive forum, perhaps on your blog or on the Savant
mailing list. Thanks for taking the time to comment.
-- pmj
|
szbeam [AT] gmail [DOT] com
2006-09-06 17:42:05 (1179)
sorry but PHP is NOT a templating language (def: a language designed
specifically for creating templates). Its a plain old scripting language
with a bizarre syntax for "print" with '?> foo <?php' being the same thing
as 'echo " foo "'
For instance just because there is such a thing as JSP does not make Java
a "templating language".
Fuecks and co. are wrong on this and many other points. I've taught
non-programmers to modify Smarty templates in a few minutes. The minute
they see <?php $this->something ?> their heads would explode, or worse yet
they would call me to help them. No thanks.
Smarty takes about 1/2 hour to learn. After the template is compiled it is
comparable in speed to a PHP-only template. And its safer, easier to read
and modify, and more re-usable.
Admittedly there is some weirdness in the syntax and it would be nice if
it was not so bloated. But you should have a strict system for separating
logic and layout, whether its this or Smarty I think is just tomato or
tomatoe.
|
ian [AT] professionaldesigner [DOT] co [DOT] uk
2006-09-04 03:06:28 (1175)
Title: Professional Designer – Website Designer UK
Description:
Professional website designer in UK offers solutions for small business
web design including custom and bespoke ecommerce website design, uk site
redesigns & web content management solutions.
Email: ian@professionaldesigner.co.uk
Name : Ian Hash
Website: http://www.professionaldesigner.co.uk
Reciprocal Link http://www.professionaldesigner.co.uk/links/links2.php
|
philip_andrew [AT] hotmail [DOT] com
2006-08-01 21:43:12 (1160)
Does it work with CakePHP? I just want a good template system for CakePHP.
|
anonymous
2006-03-30 20:33:59 (1095)
For the curious, Savant2 is licensed under the LGPL. That means you can use
it in a commercial application so long as your application cannot be
considered a "library." If your app is considered to be a library and not
an application (according to the license), then you're library will become
LGPL'ed as well.
|
my_raj_raj2 [AT] yahoo [DOT] com
2006-03-21 07:20:29 (1088)
Anybody know How maintain a common url for the whole
site.Tell me how maintain it.I used savant in the site.
|
reklipz [AT] gmail [DOT] com
2006-03-13 21:16:11 (1086)
Awesome templating system
BTW - I'm glad you fixed ur site, was browsing and there was nuthing but
errors everywhere, lol.
Working on it while I was viewing.
Thanks again!
|
chris [AT] cs-web [DOT] co [DOT] uk
2006-02-27 17:32:00 (1082)
Hurray for savant!
I just spent about an hour trying to get multi-dimensional arrays and
nested {section} tags working in smarty with no success.
Just did what I was trying to do in Savant using a couple of foreaches in
about 10 mins.
|
joel dot kronenberg at utoronto dot see eh
2006-01-16 15:17:13 (1078)
phpsavant 2 uses the PHP PATH_SEPARATOR constant which was introduced in
PHP 4.3.0.
the min requirement for phpsavant then 4.3.0.
|
illnail [AT] mail [DOT] ru
2006-01-03 08:44:40 (1074)
Well, the idea is great. It is one of the most natural ways to separate the
business logic from presentation, really (but not the only, actually). I'm
glad that you haven't forgot the compiler (even "basic"). There's a small
unpleasant issue about "<?php templates". You can't see the template markup
in WYSIWYG editors. But this stuff is significant for designer. That is why
the "{ .. }" syntax is a cure.
Thanx. I'm taking Savant for a little testdrive.
|
gert [AT] hotmail [DOT] com
2005-11-08 21:43:40 (1056)
Î÷ºþÂÃÓÎ
|
anonymous
2005-10-24 09:24:15 (979)
The thing is that your template now can, say, be only designed by yourself,
or people your trusted most - 'cause what Smarty actually does and where
costs its most energy is to "tokenize" contents, which will provide
security for the template files even they came from somebody you don't
know.
|
bzikofski [AT] gazeta [DOT] pl
2005-09-22 11:02:47 (972)
hey there
not more than few months earlier i couldnt get convinced to using template
engines (read this as: "i couldnt understand how they work"). my friend
wrote a simple one (similar to quicktemplate), and finally explained it to
me. ever since i was happy with his RSTemplate (based on {tags})
after that i thought i could give smarty a go, but it seemed to me that
learning new tags and smarty tricks is not for me, plus it's definetely too
big for my small projects.
i was searching, reading forums, articles, opinions, etc, and finally
found Savant. i haven't used it yet but i like its approach, it's not
really separating HTML from PHP but rather separating logic from
presentation (i'm kinda quoting Brian Lozier here).
{tags} type engine makes the template files "clearer" as there is no PHP
code there, <? $this->Savant ?> type engine includes some code and that's
why it makes it a bit confusing at first.
nevertheless i will definetely try it out on my new project which is
supposed to start and provide feedback here.. i appreciate the fact that
Paul M Jones is here talking to users, and that the Savant itself is still
in development, which makes it fresh - many of the templating engines have
been written once and not updated ever since.
thanks and talk to you later
PS. but...
while i look at my current project on which i work almost all the time
(intranet site at work), i can see that transition to Savant would be very
very difficult..
|
pmjones [AT] ciaweb [DOT] net
2005-09-18 13:01:12 (971)
Hi, Esad --
I'm afraid it's contra the Savant foundational ideas. :-( However, you
can write up a custom compiler of your own that does such things. Savant
comes with a compiler hook built-in; see the online doc pages.
Hope this helps.
-- pmj
|
esad [DOT] public [AT] esse [DOT] at
2005-09-17 22:41:45 (970)
Is there a way to avoid tying <?php and $this->_()? Is there a way to
suport some macros, so that one can type
{ phpcode } or [value] so that it gets preprocessed into <?php phcode ?>
and $this->_(value);
Does this make sense or is it contra all savant principles?
|
plyrvt [AT] mail [DOT] ru
2005-08-02 07:00:16 (948)
> instead, it uses PHP itself as its template language
> so you *don't need to learn a new markup system*.
Both Smarty and PHP markup a new for designers. But first is much easier
to learn/use.
|
plyrvt [AT] mail [DOT] ru
2005-08-02 06:40:52 (947)
Smarty is the best transparent generator of templates for Savant!
|
pmjones [AT] ciaweb [DOT] net
2005-07-30 10:48:31 (944)
Hi, pudeyo,
I don't generally like using the page-comments for extended
back-and-forth, but I suppose we can do so this one time. I suggest if you
want to pursue this at length, please join the mailing list, and we can go
over every point in excruciating detail. Until you decide to do so,
however, I'll respond here. :-)
You talk about the assertion that Savant is better than Smarty. All I've
ever said is that it is a "simple, elegant, and powerful" alternative. It
may be better for some uses, even most uses, but cannot objectively be
called better than Smarty any more than Smarty can be called objectively
better than Savant. I would call this an argument about semantics. ;-)
Regarding cosmetic differences: take a long look at the internals of
Smarty, then take a look at the Savant internals. I think you'll find more
than merely cosmetic differences between the two. If it's worth it to you
to have that kind of complexity and resource usage and permissions
requirements so you can use { ... } instead of <?php ... ?> then be my
guest; to each his own, etc.
With respect to not closing <?php ... ?> tags, yes, any PHP script that
you format improperly will not function properly. As Savant templates are,
by default, PHP scripts themselves, you do need to follow proper PHP
syntax. This is not something that would be addressed in Savant; it is a
function of PHP itself.
The great feature of Smarty that you have come to like, custom tags, is
easily do-able in Savant; take a look at the plugins section of the site
for examples. Maybe 5 minutes to write each one? And they'd be real
object-oriented plugins at that, not just Smarty-named functions. And if
you *really* like custom tags, you can write an entire markup compiler of
your own and hook it into Savant; this means you can have an entire custom
markup if you want one. See the "Compiler" section of this site for an
outline of how to do so, as well as the Savant2_Compiler_basic.php file.
But if "custom tags" are the best and highest use of Smarty that you've
found, then I have bad news for you: you don't really need Smarty *or*
Savant to do that. Just write a set of PHP functions and call them.
<?php
nl_div_fixed('530px');
nl_hsplit();
nl_hcell('valign="top"');
?>
Some content
<?php
nl_hcell_end();
nl_hsplit_end();
nl_div_fixed_end();
?>
Any argument that this is somehow "too much work" is disingenuous; it's at
least as much work to write the same PHP code to support those functions
and then figure out how to get Smarty to address them properly. Now, for
more-complex functions we can talk, but Savant will have an advantage over
Smarty in that Savant plugins are true objects, not just functions, and as
such can encapsulate a wide range of support functions within a single
plugin; take a look at the "form" plugin code for an example.
But all of this is academic. Your sunk-cost investments of time and
effort in Smarty notwithstanding, I'd say if you really want to find the
benefits of Savant, you should try using it. If you're not willing to
spend a half-day coding with it and really trying to learn about it on your
own (instead of just picking at it from the outside), then there's not much
else I can say.
Regardless, good luck with all your projects.
-- pmj
|
pudeyo at rpi dot edu
2005-07-30 03:01:55 (943)
I was mostly contesting the assertion that savant is somehow "better" than
smarty. Benefits of savant appear to be mostly cosmetic (i.e., someone
prefers {tag}s and someone else prefers <?php if ?>s).
I personally prefer {tag}s over <?php if ?>s. The only annoying feature of
smarty I've discovered to date is the requirement to close all of its tags
within a template, which can be worked around with plugins and more
templates. Now I've never tried this but I'd expect php to complain too if
you don't close scopes in a single file, so savant shouldn't be much better
at this.
A great feature of smarty that I've come to like on the last project is
its ability to essentially manufacture custom tags. E.g.,
{nl_div_fixed width='530px'}
{nl_hsplit}
{nl_hcell valign='top'}
Eventually some content for a change
{/nl_hcell}
{/nl_hsplit}
{/nl_div_fixed}
How much code would savant need to accomplish this? :)
(Internally the above expands to more table, tr and td tags than should be
allowed on a single page, but who cares?)
-- Oleg
|
pmjones [AT] ciaweb [DOT] net
2005-07-29 16:09:17 (942)
Hi pudeyo --
Point 1 is true, so it's not a plus or minus on either side.
Point 2 is negated if you don't use Smarty to begin with.
Point 3 is negated if you compare command-for-command the Smarty
vocabulary with the PHP vocabulary. PHP's "if()" et. al. syntax are just
as easy as Smarty's "{if ...}" et. al. syntax.
If you want to keep going, we can; I'd suggest joining the Savant mailing
list so we can incorporate your ideas as improvements to the Savant
codebase, should any apply. :-)
-- pmj
|
pudeyo at rpi dot edu
2005-07-29 15:36:29 (941)
Learning is a one-time investment, and it didn't take me long at all.
With regard to debugging,
1. you have to debug php code, so you have to debug anyway
2. smarty has great debugging support (debug console)
3. given that smarty's syntax is simpler than php's syntax, there are
fewer bugs in smarty code than in php code
|
pmjones [AT] ciaweb [DOT] net
2005-07-29 15:04:41 (940)
Hi pudeyo -- you're also trading programmer time spent learning and
debugging the Smarty markup. :-)
-- pmj
|
pudeyo at rpi dot edu
2005-07-29 14:21:51 (939)
Hang on there. In a production environment (i.e., templates are not
changing) compilation happens once at deployment, after which Smarty's
(compiled) templates are essentially equivalent to your hand-written
templates.
So, you're trading programmer time spent on typing more characters for
computer time spent compiling templates during development. Smart strategy?
|
johan [AT] jsahlen [DOT] se
2005-07-19 06:48:47 (936)
My output always contains an extra line at the very beginning (it holds
only a space character). This happens no matter where in my source files I
call Savant2's display() function, and I am sure I don't have anything
before it that could cause the extra line. Does anyone know what might be
my problem?
Thanks,
Johan
|
chris [AT] cs-web [DOT] co [DOT] uk
2005-06-18 07:57:08 (922)
Hi, I like the look of savant because it doesnt compile templates in a
complile folder (something I allways thought was pointless and my down
templating classes never use).
But I want to make my site support languages so, does savant support this?
Is it possible to have like a template of a page where its just
<h1>{errortitle}</h1><p>{errordesc}</p> and then when excecuting the
template in php have like $tpl->assign('errortitle',
registrationerrortitle);
$tpl->assign('errordesc', registrationerrordesc);
registrationerrortitle & registrationerrordesc is some kind of language
variables for the title and description of the registration error that is
stored in language files (plural because of different file for each
language) and then you tell savant what language to do the template in then
it gets the relative string for registrationerrortitle &
registrationerrordesc and esigns them toerrortitle & errordesc and
displays.
Does that even make sense, thanks Chris
|
pmjones [AT] ciaweb [DOT] net
2005-06-17 14:12:26 (920)
It's LGPL, I'll add that to the front page. Thanks for asking. (LGPL is
safe for commercial apps.)
|
anonymous
2005-06-17 14:10:46 (919)
I can't seem to find any licensing information it. Is it ok to be used in
commercial applications, for example?
|
anonymous [AT] coward [DOT] com
2005-05-19 18:38:42 (895)
I still c a n n o t beleive PEAR did not let SAVANT in. Everybody uses it.
You read about it everywhere and it's so different from _Flexy, _IT, Smarty
and so forth.
Thanks Paul.
|
skizzlesNO [AT] SPAMgmail [DOT] com
2005-03-26 21:13:09 (866)
I take that back, not only do you need to setErrorType(), but you also have
to add
include_once 'Savant3/resources/Savant3_Error_exception.php';
somewhere, as it is not loaded from the main class. Thanks.
|
pmjones [AT] ciaweb [DOT] net
2005-03-26 20:58:02 (865)
Hi, Skizzles --
I'm glad you are eager to get going with Savant3.
The forum for Savant3 is the same as for Savant2: the mailing list (click
on the "Mailing List" sub-tab above). In addition, there is an addition
area on this site for Savant3 (although it's mostly empty) -- see the
"Savant3" link on the left.
I'll start writing documentation when Savant3 is in beta stage. Right now
it's only in developent stage, so the best I can do is point you to the
heavily-commented source code.
In the mean time, please feel free to join the mailing list if you have
more questions, and thank you for your patience.
-- pmj
|
skizzlesNO [AT] SPAMgmail [DOT] com
2005-03-26 20:48:55 (864)
I was having problems throwing errors with Savant 3, the setError()
function is now setErrorType(). When the hell will the API docs and a
forum be up for Savant 3 :S
|
b6gm6n [AT] gmail [DOT] com
2005-02-27 21:01:45 (841)
why is it that i always have the error
Savant2: template source file not found
when the templates are there...it's killing me, i'm beta testing an app on
my host but it's constantly balking on this, do i need to do anything?
|
madawa [AT] technologysource [DOT] com
2005-02-18 00:42:12 (825)
Dear Sir ,
I have be a Computer Diploma in Sri lankan Institute and I have be a NASA
(USA)Membership in Space Division
Because I would like to jopin and work in your company , Please Sir
Thank you,
You Faithfully,
Madawa Lakmal Gunasekara.
|
vnjug [AT] yahoo [DOT] ca
2004-12-19 08:23:04 (721)
Is there any Savant Renderer/Filter for Mojavi framework?
thks
|
pmjones [AT] ciaweb [DOT] net
2004-12-14 18:47:46 (718)
Hi, JanusJr --
I am afraid an E_STRICT version is several months away. I have two
options, really: I can make the current 2.x series E_STRICT compliant, or
I can work on a Savant3 that is E_STRICT compliant **and** makes use of
PHP5 features (magic methods and so on). I'd rather do a Savant3, but that
will take time, and there are other projects that need to be finished. I
hope you are not too disappointed.
-- pmj
|
janusjr [AT] tdcadsl [DOT] dk
2004-12-14 18:41:21 (717)
Yes, I found $Savant->setError('exception') thanks you :)
What I would really like, is an PHP5 E_STRICT version - is this coming
anytime soon ?
|
pmjones [AT] ciaweb [DOT] net
2004-12-13 19:20:20 (716)
If Exceptions are what you require, check out the customized error
handling; if you call $Savant->setError('exception') then Savant will throw
exceptions in addition to returning error objects.
|
janusjr [AT] tdcadsl [DOT] dk
2004-12-13 19:15:52 (715)
This is much much better than Smarty (learning a new markup system is a
waste of time!).
All we need now is a pure PHP5 version of Savant with Exceptions and all
:)
|
alex [AT] sourcelibre [DOT] com
2004-12-09 12:15:53 (700)
In version 2.3.2, the directory Savant2-2.3.2
Folder/Savant2-2.3.2/Savant2/tests are really usefull. I almost always
prefer examples to explanations, and these examples are just perfect.
aalex
Mille mots valent une image
|
anonymous
2004-11-19 12:54:32 (668)
A downloadable documentation would _REALLY_ help. ^_^
|
pmjones [AT] ciaweb [DOT] net
2004-10-22 08:41:33 (615)
Hello, you, yourself, and ye --
Savant isn't an application, exactly; it's more of a library. There
aren't any screenshots. The closest thing to a demo is an example use of
the code, on the Documentation section under "Getting Started/Quick
Example". Hope this helps.
-- pmj
|
memyselfandi [AT] aol [DOT] com
2004-10-22 07:15:32 (614)
I´m looking for a demo or some screenshots.
|
millette [AT] waglo [DOT] com
2004-10-08 13:21:09 (594)
pookey said:
"When I explain Savant to people, I never call it a templating
engine, because, in my opinion, that puts it in the Smarty category. This
is a templating system, there is no engine, it's just PHP."
Same goes for me, I generally present Savant as a methodology, part of a
coding style. I gave a presentation last night introducing (in french) to
Savant2 you can find here:
http://newton.waglo.com/~millette/presentation-savant/
I'm going to be improving it a lot in the next few days, and generally
over time.
|
pookey [AT] pookey [DOT] co [DOT] uk
2004-10-07 07:09:38 (584)
Firstly, Thanks to the author for a fantastic templating engine. I read a
few articles that pointed out how insane the approach that smarty and other
such templating engines take is. Why write a custom language with in PHP
just to handle displaying things? Some people would say 'yes.. but Smarty
can compile a template into PHP!'. Fantastic, why not write it in PHP in
the first place? My designer and I work perfectly with Savant2, completely
separating out the business logic and the display logic.
I vowed not to use a templating engine after getting annoyed with Smarty
bloat. When I explain Savant to people, I never call it a templating
engine, because, in my opinion, that puts it in the Smarty category. This
is a templating system, there is no engine, it#s just PHP. This is a well
written, fast, simple and effective templating system, and I would advise
it to anyone who is looking for an effective way of seperating display and
business logic.
|
alien [AT] echoing [DOT] org
2004-08-13 03:20:29 (481)
i shall ask my mistress to test this system out.
|
pmjones [AT] ciaweb [DOT] net
2004-08-02 22:24:31 (456)
Hi, anonymous --
Savant2 will run under PHP5 with E_ALL but not E_STRICT, because E_STRICT
requires that properties and function be declared as public, protected,
private, etc. A later version of Savant2 will be PHP5 E_STRICT compliant.
Hope this helps.
-- pmj
|
anonymous
2004-08-02 19:34:37 (455)
Looking over this website and the mailing list, I can't tell whether Savant
2 is PHP5-ready. Is it? And if not, is there something like it that I can
use under PHP5? Thanks.
|
pmjones [AT] ciaweb [DOT] net
2004-07-27 10:49:33 (449)
Hi, gi0001tw --
Savant2 runs without PEAR. Savant2 is in beta right now; click on the
"Savant 2 Development" tab at the top of the page for more information.
-- pmj
|
gi0001tw [AT] yahoo [DOT] com [DOT] tw
2004-07-27 10:10:11 (448)
Can Savant run without PEAR?
What if I change it not to use PEAR? Is it a easy job or not?
|
elmo [AT] elmosaukko [DOT] com
2004-07-12 15:39:58 (423)
Exemplary simplicity and ease-of-use!
|
cyberlot [AT] cyberlot [DOT] net
2004-07-04 15:10:56 (405)
Nevermind my last im stupid you cant redeclare a function, The only
feasible way to do this would be to use safe_mode disable ability
disable_functions readfile,system
However this would disable the functions for the whole script which would
not work either and is only allowed in php.ini not even .htaccess.
Now if you could set disabled functions through some other means you could
work it out.
|
cyberlot [AT] cyberlot [DOT] net
2004-07-04 15:05:25 (404)
I had a thought about that problem but I see the overhead being a bit
large..
You can "overwrite" functions by redeclaring them, so you would need to
redeclare everything
function system() {
return 'Command Disabled';
}
But the overhead of doing that, AND having the ability to turn functions
on and off might be a bit much??
|
anonymous
2004-07-03 14:45:12 (403)
Restricting the use of some php built in commands is important, especially
in a "template engine". Is there even a way to do this without having to
parse the template with your custom meta-language or parser? Maybe there is
some php extension somewhere?
|
cyberlot [AT] cyberlot [DOT] net
2004-06-28 17:19:55 (391)
One other comment, These templates can break the whole page, While
smarty/other methods the worst a developer could do in most cases is screw
up how the page looks, not keep it from displaying at all.
|
cyberlot [AT] cyberlot [DOT] net
2004-06-16 16:42:56 (363)
I am re-working a site from scratch and had started using smarty till I
found this. It only took a couple hours to change everything over and its
great and speedy.
There is however a single downside I see. Since your parsing php directly
there is no way to control what functions can and can not be used. This
makes savant harder to use for example on a theme based forum or cms. You
can now no longer give any admin person the ability to manage the templates
as they could hide standard php in the template.
|
cyberlot [AT] cyberlot [DOT] net
2004-06-16 16:42:33 (362)
I am re-working a site from scratch and had started using smarty till I
found this. It only took a couple hours to change everything over and its
great and speedy.
There is however a single downside I see. Since your parsing php directly
there is no way to control what functions can and can not be used. This
makes savant harder to use for example on a theme based forum or cms. You
can now no longer give any admin person the ability to manage the templates
as they could hide standard php in the template.
|
pmjones [AT] ciaweb [DOT] net
2004-05-16 13:51:52 (269)
Hi, electr0n --
I'm sorry, but I have no plans to include caching as part of Savant. Even
with PEAR, Savant templates are usually faster than compiled templates.
To me, caching should happen at the application level, not the library
level. That way, your cache is consistent across the entire application,
and you don't have different caching mechanisms for disparate library
components (and you only have to remember one API for you cache).
If you need a cache, I suggest PEAR Cache_Lite; it is fast and easy to
use. It will cache output, as well database row results and function
returns.
Alternatively, if you want a simple foundation for PHP apps that includes
caching (and logging, and authentication) I suggest using Yawp, which is
also PEAR based.
http://wiki.ciaweb.net/yawiki/index.php?area=Yawp
(soon to be at phpyawp.com :-)
Hope this helps.
|
electr0n [AT] c0ders [DOT] de
2004-05-16 13:41:49 (268)
Sure :) Now I am using Savant, because I don't like Smarty :P.
But with PEAR Savant isn't so fast anymore, whatever Savant is great, have
you planned a caching feature for Savant?
cheers,
|
pmjones [AT] ciaweb [DOT] net
2004-05-15 11:07:49 (262)
Hi, electr0n -- Savant depends on PEAR for error reporting. While a new
version might use something other than PEAR for errors (probably through
customized error routines) it would be a major backwards compatibility
break. As such, that would mean version 2.0 or later. I am planning for
version 2.0 to be PHP5 compatible (indeed required) and as the dependency
on PEAR is the single most reasonable complaint about Savant, I will
seriously consider it. In the mean time, I know you don't like PEAR, but
maybe Savant makes PEAR worth the trouble for now? (Well, I can hope,
right? :-)
|
electr0n [AT] c0ders [DOT] de
2004-05-15 11:01:58 (261)
Is it possible that the next version of savant can be used without PEAR? I
don't like Pear very much and the performance of Savant will be decreased
from the PEAR Framework.
cheers,
|
pmjones [AT] ciaweb [DOT] net
2004-05-15 00:08:13 (259)
Hi, anonymous -- I think that's the most intelligent comment on the whole
page. Well said. -- pmj
|
anonymous
2004-05-15 00:03:12 (257)
Responding to Toni (quoted):
"We cannot really separate layout and data, for sometime we need layouting
in the logical layer layout and in the other side layout needs to know the
data to suit its design. It's a demon's circle."
What you're describing is the *semantics* of the layout vs. the visual
look and feel. This is why the w3c is finally telling people to stop using
tables to layout their pages; tables were meant to establish the semantic
relationship of a "data table" but can no longer be assumed to be doing so
because they turned out to be the only good way to arrange visual elements
on the page.
The BR tag, the : (colon) character, and many others do this, too. So, for
example, on a page you see this:
Title:
Manager
In order to properly separate content from design, you need to find out
what your semantic relationship are. Was that BR between Title: and Manager
simply because you wanted to start a new concept on a new line, or because
you wanted to visually like Title: to Manager by way of the spacing shown?
Incidentally, this is one of the argument in favor of Python-esque
"whitespace as syntax." Your application should deliver these two data
points in some type of a tuple, which the template engine can then arrange
(a tuple is a finite ordered set, like coordinate points in geometry,
except that there can be any number of points).
If you find yourself needing to shove tags in from your application and
logic in order to get things looking right on screen, that's the number one
indicator that you didn't design the template and/or the semantic
relationships correctly and should go back and tweak the design as a whole
rather than tweaking the HTML from the application.
|
gurugeek [AT] php [DOT] net
2004-05-14 16:19:28 (256)
After Smarty I promised to myself that I would stay away from any template
engine/system till I found Savant.
Really nice, great concept to keep it dead simple yet to have the chance
to use an OO separation between the code and the html.
Please keep up the good work, don't listen to the comments posted by
Smarty freaks. Smarty is a curse, bloathed, slow, and hard to learn,
maintain and use.
Kudos, keep up the great work,
David Costa
|
pmjones [AT] ciaweb [DOT] net
2004-05-12 00:23:48 (247)
Hi, deHead -- there's no strange template language involved, everything is
in native PHP. The only interface is the assignment of variables (and
choosing of template) from the business logic, and the calling of plugins
from the template itself. Everything else is plain vanilla PHP, which of
course any PHP developer can read. :-)
|
pmjones [AT] ciaweb [DOT] net
2004-05-12 00:21:43 (246)
Hi, Daniel,
What you outline is very like the PHPTAL (template attribute language)
project. It looks nice; I hope it serves your needs (and perhaps the needs
of others!).
But Savant is about using PHP itself for the template language, not about
building new languages or parsing systems. Savant is fast and easy because
it doesn't attempt to compile, parse, or interpret the code before
processing it with PHP: the template is itself PHP.
I can guarantee that Savant will always be faster and easier to read (for
the majority of PHP developers) than the system you outline. The only way
for Savant to be slower is if you cache the output from your system, and of
course a developer can cache Savant output as well with any caching system
he likes.
Regardless, good luck with your project; a lot of people like the TAL-like
templates, so there's certain to be demand for it. :-)
|
deHead [AT] singapoor [DOT] edu
2004-05-11 22:52:37 (245)
incredible! you have a build construct (i don't like to say template engine
in this case) that is harder to use, read and
to develope with than with plain php (in ravioli style)!
Try the same without strange template language.
It will be much easier...and faster...
|
daniel [DOT] nospam [AT] holomind [DOT] de
2004-05-11 19:03:36 (244)
Sorry, missed some comment ;) The Examples i showed is from my own
templatesystem which is based on some regularexpression replacements, and
enhances readability of templates very much. it replaces -> with . like in
java, as i do all in php, but like the .-notation in templates better, also
it the ">" is problematic in <html>, because of closing bracets etc.
There is no need for "assigning" things, so you use global objects, and
due to objects, there is no spagetti-globalising, but very clean
maintainable code. the "loader.get_kat() ; loader.next_record" is
object-calling of a db-abstraction similar to pear-db, but much easier.
Perhaps somebody can comment this as "1-cool ... 5-bu**shit"
i use it and prefer to all other template engines.
inventions for the world ;)
|
daniel [DOT] nospam [AT] holomind [DOT] de
2004-05-11 18:56:43 (243)
<?php
require "../../../../_lib/main.php";
$tpl = "home"; #on default use this template
eval
( $page -> _parse_more('index._'. $tpl .'--tpl.php') );
?>
#--- all < !--- --- > comments are hidden like in coldfusion
#--- serverside comments, this comments are only for making
#--- code better readable, and not needed to define blocks!
#--- echoing request-values
<td width=348 valign="top" bgcolor="#CCCCCC">
<!--- headline --->
<img border="0" src="_img/_head/headline_{request.html p}.gif">
<!--- /headline --->
</td>
#/// means, {request.html p} is translated into
<?php echo htmlentities($_REQUEST('p')); ?>
#--- calling submodules and doing if-statement
<!--- mod --->
<tpl:if ( REQUEST('tipp_ID') _gt_ 0 )>
<?php require_once('tipps/tipps-detail--tpl.php'); ?>
</tpl:if>
<!--- /mod --->
#--- <tpl:if (...)> is translated into, you decide
#--- which is cleaner in html ;)
<?php if ( $_REQUEST('tipps_ID') > 0 ) { ?>
...
<?php } /** endif **/ ?>
#--- submodule
#--- navig.inc.php
<?php
require "navig/_navig_status.class.php";
$nav = new Navig_Status;
?>
#--- and matching template
<tpl:eval ('require_once "navig/_navig.inc.php";') />
<tpl:for ($count=0, loader.get_kat($kategorie) ;loader.next_record;
$count++)>
<a href="?{request.param p}&k={loader.url kategorie}">
| » {loader.html kategorie}
</a><br>
<tpl:if (loader.f text != "")>
{loader.f text}
</tpl:if>
</tpl:for>
Enough Examples,
To make a fast explanation: <tpl:{something} ({funktion}) />
will be translated into its php-counterpart/php-code.
<?php {something}( {function} ); ?>
but some smart code-cleanup and better OO is given.
#--- tpl-markup (readable)
loader.get_kat($kategorie)
#--- is tranlated to a cool objectcall (pure php)
<?php $loader -> get_kat( $kategorie ); ?>
there are only a few rules which fit on a A4 Page Printed, the rest is
mapping
all php-functions.
Caching of Templates is also available.
The Template-Code (without libraries is less than 1000Lines of code)
|
ghostwwinside [AT] gmx [DOT] net
2004-05-03 17:55:39 (202)
SAVANT LITE
""""""""""""
#-- myhomepage.php
$title = 'myHomepage';
$arr = array([0]=>'peter', [1]=>'elfriede');
#-- myhomepage.html.php
<?php include('myhomepage.php'); ?>
<html>
<head>
<title><?php echo $title; ?></title>
</head>
<body>
<?php foreach ($ass as $value) { ?>
Hello <?php echo $value; ?> !! <br />
<?php } ?>
</body>
<?php include 'cache_file.php'; ?>
#-- am i kidding
i dont know?! but in fact smarty has much more
features. i think the features are easier to
use for non programmers.
when i wait for 0.05s on every smarty caching
and none for Savant i'll decide to take TE with
more features, functions whatever.
#-- having illusions %)
i think there could be a big use of an unified
template language in future (like SQL for DBs).
maybe one syntax for different languages (perl,
php, ruby, phyton etc).
using special template syntax is a must have for
TemplateEngines, it makes the project a bit slower
in some cases, but in extreme cases you can use
the same template with another language.
hmm, maybe i drunk too much this nite, but
now i think it's a great idea to think about
an unified template syntax ;)
think about it...
|
pmjones [AT] ciaweb [DOT] net
2004-05-02 14:24:16 (198)
Hi, a@b.c --
Among other things, Xipe compiles its templates, and Savant does not.
Even though Xipe uses PHP as its language, it still compiles the
templates, which adds to time and overhead on the first processing pass
(and perhaps subsequent passes). Savant uses plain PHP and does not need
to compile.
Xipe uses variables directly from the script, without a step for
"assigning" them to the template; Savant uses an explicit "assign()" method
to push variables to the template.
Xipe implements its own cache. Savant leaves caching for the application
and does not try to override that.
The documentation for Xipe is not complete, although it does come in three
flavors (.html, .sxw, and .pdf); Savant docs are complete and online with
comments enabled. :-)
Xipe does not appear to have a plugin system like Savant, although it does
have a similar filter system (but there's no documentation on how to write
your own filters). The benefits of a plugin system are debatable.
Xipe tries to add new template language elements (the SimpleTag language),
tries to interpret indents, and so on. Yes, you can "turn off" those
features but you have to know about them to do that. Savant uses PHP, all
of PHP, and nothing but PHP, in normal PHP format (ugly long tags and
everything ;-).
In short, the "simplicity" of Xipe takes some time to learn and get used
to; Savant is just PHP right out of the box.
None of this is to say that Xipe is bad; it is certain that it appeals to
many developers (e.g., its translation routines look quite nice). I like
Savant instead.
To paraphrase Monte (below): to each his own, use what you like.
(Actually, he says "use the right tool for the job" but there can my more
than one "right tool" I think. :-)
Please feel free to join the mailing list if you have more questions;
thanks. :-)
-- pmj
|
a [AT] b [DOT] c
2004-05-02 06:39:28 (197)
Hi PHPSavant developers!
Could you please outline the major differences of Savant compared to
HTML_Template_Xipe? To me it seems these two projects have the same goals
but Xipe is easier to use (no need for <?php ... ?> and automatic echoing
of values). I am referring to Xipe using the SimpleTag language here.
What does Savant offer over Xipe?
Thank you!
Xipe can be found here: http://pear.php.net/package/HTML_Template_Xipe
|
pmjones [AT] ciaweb [DOT] net
2004-04-30 10:54:04 (191)
Hi, Monte -- you said the same thing in January; the comment is still there
for everyone to see. :-)
|
monte [AT] ispi [DOT] net
2004-04-30 10:35:34 (190)
pmjones, your comment on Smarty cache is misinformed. The Smarty cache is
merely a snapshot of the _output_ of the generated web page (which is made
of one or more template files.) Smarty compiles template files into PHP
scripts only once, regardless if caching is enabled or not. Two separate
things.
|
have you gave me ?
2004-03-14 05:40:22 (50)
Template System for PHP
|
have you gave me ?
2004-03-14 05:40:02 (49)
hi ..
have you gave me simpel web for Template System for PHP
|
toni [AT] mataramsuryavisi [DOT] com
2004-02-28 14:18:33 (42)
I don't want to add some more sands into the water. I have never use savant
for I have to conquer some issues regarding my PEAR installation.
Nevertheless, I would like to remind us all that what the web designer and
web programmer need is (maybe) a more clear separation betwenn logical
layer and presentation layer. Eventhough, somehow, I think it's almost
imposible. We cannot really separate layout and data, for sometime we need
layouting in the logical layer layout and in the other side layout needs to
know the data to suit its design. It's a demon's circle.
|
prelude_2_murder [AT] yahoo [DOT] co [DOT] uk
2004-02-17 04:48:09 (40)
Another advantage when compared to smarty is that you don't have to use
{literal} to "hide" your javascript/css.
|
barnie [AT] apexavia [DOT] net
2004-02-13 04:39:47 (39)
I wonder how to install and run these applications. The "exceptionally
well-commented" code tells me everything about each tag, variable, etc (why
bother?) but doesn't say anything about usage of the program. As a result I
create blank screens all over the place.
|
monte [AT] ispi [DOT] net
2004-01-12 17:43:36 (31)
[quote]
Smarty caching is a byproduct of its need to compile a template into PHP.
If Smarty had to compile new PHP code every time it called the same
template, its performance would suffer dramatically; thus, Smarty caches
compiled PHP scripts primarily for its own performance. Once the cache
exists, there are other uses for it, but those uses are entirely secondary
as far as Smarty is concerned.
[/quote]
I'd like to correct the statement quoted above, it is a bit incorrect.
Here is a little overview of how template compiling and template caching
work in Smarty.
Without caching, Smarty compiles the templates: meaning it takes each
template file, converts it to a PHP script and stores that script in a
compile directory. This step happens only _once_ when the template is
initially requested. From that point on, the compiled PHP script is
executed and the original template file is not used anymore. If the
original template file is updated, only then does the compile step repeat
once. Smarty does _not_ repeatedly compile the templates on each request.
PHP
With caching on, the _output_ of the display() call gets cached to a text
file. The cache is not per template but per display() call, so basically
the output of a single browser request which could be comprised of one or
more templates. This cache file is then used on subsequent calls to
display() instead of assigning content and running the PHP interpretor over
the compiled templates on each call.
The caching features of Smarty are not a by product of anything, just and
additional feature. There is no problem running Smarty without caching, it
is still as fast as executing a PHP script.
Savant basically skips the compiling step, so the PHP scripts are the
original template files. That may be fine for some but maybe not for others
(ie template security). The proclaiming mantra of "almost all the power,
almost none of the overhead" is a blanket statement that screams flamebait,
you are really comparing apples to oranges. In fact, it seems that most
template engines likes to pit themselves against Smarty, so that should
tell you a little something about Smarty eh? ;)
The reality is you cannot make a hammer that works with every nail, you
just use the right tool for the job. In that respect, it's good to see yet
another tool added to the arsenal for PHP developers.
|
pmjones [AT] ciaweb [DOT] net
2003-12-15 16:10:56 (28)
Hi, Capitola200 -- you need to have PEAR installed; Savant depends on it
for error handling.
http://pear.php.net
|
capitola200 [AT] yahoo [DOT] com
2003-12-15 15:57:54 (27)
I've looked around and I can't find an answer to this. I'm probably missing
something very simple.
-----------------------------------------------------------
Display non-existent template
Fatal error: Call to undefined function: throwerror() in
/usr/www/www.bmbl.net/Savant-1.2/Savant.php on line 816
-----------------------------------------------------------
Thanks!
|
jm [AT] infodos [DOT] com
2003-12-11 23:20:19 (22)
Ok. I will write in mailing list.
For the question of include_path, i resolved it.
For the question of error example options not.
|
pmjones [AT] ciaweb [DOT] net
2003-12-11 22:28:37 (21)
Hi, jm,
I intended these comment sections to apply to each individual page on the
site, not as a question and answer forum in general. If you like, please
join the mailing list and ask detailed questions there; as enough people
ask the same questions, I'll add pages to the site that cover them.
Thanks. :-)
|
jm [AT] infodos [DOT] com
2003-12-11 21:15:35 (20)
I check the examples of this plugins: checkbox, radios, and options. The
last have an error.
This is the view code:
<html>
<select name="something" multiple="multiple">
<br>
<b>Warning</b>: Invalid argument supplied for foreach() in
<b>c:\apache\htdocs\Savant\Savant.php</b> on line <b>1084</b><br>
<br>
<b>Warning</b>: call_user_func_array() expects first argument,
'Savant_Plugin_options::options', to be a valid callback in
<b>c:\apache\htdocs\Savant\Savant.php</b> on line <b>1118</b><br>
</select>
</html>
|
jm [AT] infodos [DOT] com
2003-12-11 19:55:59 (19)
I'm have a question:
I try with Savant but, I have change the path to Savant/Plugin.php in all
files of plugins.
I put this:
require_once 'c:/apache/htdocs/Savant/Savant/Plugin.php';
In my hosting I don't have permit to put this directory in PEAR
directory.I have to use the templates in one directory of my hosting.
That's occurred because you use include path.
Am I in mistake? What is the way to install well.
Thanks.
Note: The new comments have to generate a mail to notify a new comment at
all persons that write in comments posts.
|
pmjones [AT] ciaweb [DOT] net
2003-12-11 12:24:20 (18)
Hi, jm -- I added the <tr>...</tr> tags to the example. Thanks for
catching that.
|
jm [AT] infodos [DOT] com
2003-12-07 20:13:31 (16)
Sorry, i put the code right to:
<?php foreach ($book as $key => $val): ?>
</tr>
<td><?php echo $val['author'] ?></td>
<td><?php echo $val['title'] ?></td>
</tr>
<?php endforeach; ?>
|
jm [AT] infodos [DOT] com
2003-12-07 20:11:43 (15)
I'm agree with you.
The best idea is the most simple and Savant template is easy and powered.
Please change example code are wrong. Put TD /TD in foreach:
<pre>
<?php foreach ($book as $key => $val): ?>
</tr>
<td><?php echo $val['author'] ?></td>
<td><?php echo $val['title'] ?></td>
</tr>
<?php endforeach; ?>
Please, sent me a notify when done new release.
|
ted [AT] coolfactor [DOT] ca
2003-11-27 08:10:20 (13)
I've recently converted a SmartTemplate-based site to Savant for testing
purposes. I've very happy with Savant, and conversion is almost effortless,
except for one thing.
If you assign an undefined variable to the template, the throwError()
method isn't called, or can't be found, or something.
The method is defined just below where it's called from, so I'm not sure
why it doesn't handle it.
Ted
|
linusberglund [AT] comhem [DOT] se
2003-11-17 11:55:22 (11)
An answer to anon (down there):
Sure, i like smartys syntax, though smarty is to slow.
I once helped develop a template engine ( i only made part of the
renderer) which is at least twice as fast as smarty.
I have one old copy of it on my computer, though sadly, there arent any
newer copys because the real authors computer broke down (filesystem
error). It has a similar syntax, and it has template PHP support if you
would like that.
To cache the result you can just use cachelite or some other cache tool.
|
pmjones [AT] ciaweb [DOT] net
2003-11-13 19:39:45 (10)
Hi, Julian --
Smarty caching is a byproduct of its need to compile a template into PHP.
If Smarty had to compile new PHP code every time it called the same
template, its performance would suffer dramatically; thus, Smarty caches
compiled PHP scripts primarily for its own performance. Once the cache
exists, there are other uses for it, but those uses are entirely secondary
as far as Smarty is concerned.
Savant allows the developer to cache or not, and to use the
application-specific caching system. I suppose it would be easy to add
caching to Savant, but I'd prefer not to -- caching, to me, is a function
of the application, not a template component.
I can't say much about the Smarty modifier system, other than it depends
completely on the Smarty compiler and duplicates functions already native
to PHP. Savant does have the 'modify' plugin, and while it serves a
similar purpose, it is not directly comparable to Smarty modifiers.
|
julian [AT] tiddly-pom [DOT] com
2003-11-13 18:03:24 (9)
"so it sports almost all of the power of Smarty with almost none of the
overhead."
Bold claim. Your caching API certainly looks so simple it's... missing.
Remember also that Smarty's modifier syntax is really nice to write, even
if you don't know PHP; I'm not sure how you could be that expressive in <?
$PHP->syntax; ?>
But it's always good to see new takes on old ideas, and maybe 2.0 will be
worth a look.
|
junk [AT] steti [DOT] com
2003-11-13 13:36:53 (8)
anon [AT] anon [DOT] org is it? I am guessing you're worried about flames,
probably with just reason, and for that reason I forgive your hiding.
The single biggest issue I have with Smarty, is that it is a language
(read not PHP). It sometimes uses structures similar to PHP, but it isn't
PHP. Savant, is PHP.
Now, I don't have the right to really bash Smarty as I have only used it
on a couple of occasions. Most of the template systems I have used before,
such as XSLT, add a new language layer to design. You can't simply just
know how to program in PHP (possibly a DB as well), you have to know
another language.
You can tell me all day long that Smarty is easy to learn, but with having
to compile templates, caching nigthmares, and a new language to top it off
I don't see it having any advantages. As of now though, I think we will
have to aggree to disaggree, and make the best of this topsy-turvy PHP
world we live in.
|
pmjones [AT] ciaweb [DOT] net
2003-11-12 08:12:59 (6)
Hi, anon@anon.org -- see the comments from Harry Fuecks and Brian Lozier
...
http://www.phppatterns.com/index.php/article/articleview/4/1/1/
http://www.massassi.com/php/articles/template_engines/
...for answers to those questions.
|
anon [AT] anon [DOT] org
2003-11-12 01:31:06 (5)
So why exactly is this better/simpler than Smarty? Smarty does all this and
more -- and with a better syntax, IMHO. Recall, its not only the developer
whose needs are addressed by Smarty, but the designer too. Where is the
elegance of Smarty modifiers? Where is the fine grained security? I'm not
knocking the efforts put into this project, but Smarty sets a high bar --
not merely because it uses a simpler syntax.
peace
|
linusberglund [AT] comhem [DOT] se
2003-11-11 14:05:46 (4)
PHPSavant is great!
It kicks smartys ass!
|
New comments are disabled.
|
|