You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Darko Krizic <DK...@ProDyna.de> on 2000/07/27 11:26:45 UTC

Templating system

I want to write a new application using mod_perl but this time I want to
completely divide the code from the HTML. Therefore I am seeking for a
powerfull and fast templating system.

Newly I did something with Enhydra (Java Servlets) and they have a pretty
neat templating system: They use standard HTML and one uses the "id"
attribute in HTML tags to access them and manipulate values/contents. For
example:

<table id="results">
	<tr id="resultheader">
		<th>Name</th>
		<th>Count</th>
	</tr>
	<tr id="singlerow>
		<td id="row_name">example name</td>
		<td id="row_count">example count</td>
	</tr>
</table>

The program now can repeat the tr "singlerow" for each table row and insert
it under the tr "resultheader". The values can be inserted into the tds
"row_name" and "row_count". The main advantage is: The designer can generate
HTML pages that can be viewed with a standard browser.

Does anybody know something similar for Perl?

...darko



Re: Templating system

Posted by David Hodgkinson <da...@hodgkinson.org>.
Darko Krizic <DK...@ProDyna.de> writes:

> The program now can repeat the tr "singlerow" for each table row and insert
> it under the tr "resultheader". The values can be inserted into the tds
> "row_name" and "row_count". The main advantage is: The designer can generate
> HTML pages that can be viewed with a standard browser.
> 
> Does anybody know something similar for Perl?

Hmmm. Depends what you mean. I think in your context, the Template
Toolkit has many more obvious tags that will litter themselves in the
HTML. However, using includes and macros effectively you reduce the
amount of cruft in the code.

Dave // Currently boring for England on the subject of the TT.

-- 
Dave Hodgkinson,                             http://www.hodgkinson.org
Editor-in-chief, The Highway Star           http://www.deep-purple.com
      Apache, mod_perl, MySQL, Sybase hired gun for, well, hire
  -----------------------------------------------------------------

Re: Templating System

Posted by Roger Espel Llima <es...@iagora.net>.
Darko Krizic <DK...@ProDyna.de> wrote:
> ... 
> <table id="results">
>       <tr id="resultheader">
>               <th>Name</th>
>               <th>Count</th>
>       </tr>
>       <tr id="singlerow>
>               <td id="row_name">example name</td>
>               <td id="row_count">example count</td>
>       </tr>
> </table>
> ...
> The problem with many templating systems is the fact that they invent a new
> language like "<td>$variable</td>" which is usually not displayable in the
> Browser so that the designer and the programmer must work tightly.

The designer has to learn 'id="row_name"' in one case, and $row_name in
the other.  I'd say that the need to work tightly with the programmer is
pretty much the same: you have to agree on a syntax for gaps that code
can fill, and on the names of the individual gaps.

> What other templating systems do exists that are usefull?

There is a real plethora of templating modules: the Template Toolkit,
HTML::Mason, HTML::DynamicTemplate, Text::TagTemplate and HTML::Template
can all do things like these.

They often differ in the calling approach: does the URL map to a script
which inits and calls a template object giving it values, or does the
URL map to the final template, which calls perl code to fill the gaps?
Within this there are many approaches too, different ways to draw the
line between what goes in the perl and what goes in the template, and
what kind of object model (if any) they implement.

I'm just about to release (next week) a templating/content-handling
module for mod_perl, called iAct, which takes the approach that URLs map
to template files, which call perl if they want, but then the perl code
can also manipulate templates and sections.  I'm not saying this is
necessarily the most appropriate for you, just letting people know about
it :) 

Under iAct, you'd do it like this:

<table>
  <tr>
    <th>Name</th>
    <th>Count</th>
  </tr>
  <% section "one_row" %>
    <tr>
      <td><$ row_name $>
      <td><$ row_count $>
    </tr>
  <% /section %>
  <% call sub="Your::Module::fill_rows" repeat="one_row" %>
</table>

and the code for Your::Module::fill_rows would be something like:

sub fill_rows {
  my ($self, $args) = @_;
  my ($sec, $ret) = ($args->{repeat}, "");
  foreach my $nc (&get_name_counts()) {
    $self->assign_raw(row_name  => $nc->[0],
		      row_count => $nc->[1]);
    $ret .= $self->fetch($sec);
  }
  $ret;
}

-- 
Roger Espel Llima, espel@iagora.net
http://www.iagora.com/~espel/index.html

Re: Templating system

Posted by Yann Kerhervé <yk...@cyberion.net>.
On Thu, Jul 27, 2000 at 11:03:16AM -0700, Douglas Wilson wrote:
> 
> > -----Original Message-----
> > From: Paul J. Lucas [mailto:pjl@barefooters.org]
> > Sent: Thursday, July 27, 2000 10:11 AM
> > To: modperl@apache.org
> > Subject: Re: Templating system
> > 
> > 
> > On Thu, 27 Jul 2000, Jeffrey W. Baker wrote:
> > 
> > > On Thu, 27 Jul 2000, Paul J. Lucas wrote:
> > > 
> > > > 	http://www.best.com/~pjl/software/html_tree/
> 
> I've been researching templating systems for the past few days,
> I come in this morning, and here's 40 or so posts on the very
> subject. I've been wanting one where the template is as much like
> plain html as possible, and this seems to fit the bill.
> 
> Until now I've been leaning toward the Template Toolkit, if only
> because the template elements can be filled in with other templates
> (maybe that's just in the beta version, I forget). We'd like to just
> have a standard Header/Footer, but have the Header & Footer be
> based on what client we're hosting, and the only template kit
> I could see that had variable includes was HTML::DynamicTemplate.
> 
> I'm going to have to make some decision soon, so we can start getting
> some work done :)
> 
> Can anyone point me to some examples (to accelerate the learning
> curve) with this HTML::Tree?? Or any other pointers, opinions?

As far I know (I'm a today-newcomer on the list - but I've done my best
to read previous messages in archives), no one speaks really about
HTML-Template (from Sam Tregar) . What I like (and what seems to 
interest you):

- HTML-TAGs style : <TMPL_TAG> (thus you can preview the design in a
  browser)
- Few and simple tags
- loops (to handle tables)
- includes (So, there's at least another one than DynamicTemplate :)
- cache system (who works with mod_perl with IPC system)
- (obviously, no embedded perl in html, so it's highly maintenable)

Hope this helps

-- 
Y a n n   K e r h e r v é                            | yk@cyberion.net
Developer EdenJob, Webmaster Esiea-Ouest             | ICQ:   43893215
Perl Mongueur,  Linux,  Linux-Alpha, ...             | TEL: 0146217695


RE: Templating system

Posted by Perrin Harkins <pe...@primenet.com>.
On Thu, 27 Jul 2000, Douglas Wilson wrote:
> Until now I've been leaning toward the Template Toolkit, if only
> because the template elements can be filled in with other templates
> (maybe that's just in the beta version, I forget). We'd like to just
> have a standard Header/Footer, but have the Header & Footer be based
> on what client we're hosting, and the only template kit I could see
> that had variable includes was HTML::DynamicTemplate.

That should be pretty easy in most of these systems.  TT can definitely do
it (version 1 and version 2), and so can perl-in-HTML systems like Mason.

- Perrin


RE: Templating system

Posted by Douglas Wilson <do...@racesearch.com>.
> -----Original Message-----
> From: Paul J. Lucas [mailto:pjl@barefooters.org]
> Sent: Thursday, July 27, 2000 10:11 AM
> To: modperl@apache.org
> Subject: Re: Templating system
> 
> 
> On Thu, 27 Jul 2000, Jeffrey W. Baker wrote:
> 
> > On Thu, 27 Jul 2000, Paul J. Lucas wrote:
> > 
> > > 	http://www.best.com/~pjl/software/html_tree/

I've been researching templating systems for the past few days,
I come in this morning, and here's 40 or so posts on the very
subject. I've been wanting one where the template is as much like
plain html as possible, and this seems to fit the bill.

Until now I've been leaning toward the Template Toolkit, if only
because the template elements can be filled in with other templates
(maybe that's just in the beta version, I forget). We'd like to just
have a standard Header/Footer, but have the Header & Footer be
based on what client we're hosting, and the only template kit
I could see that had variable includes was HTML::DynamicTemplate.

I'm going to have to make some decision soon, so we can start getting
some work done :)

Can anyone point me to some examples (to accelerate the learning
curve) with this HTML::Tree?? Or any other pointers, opinions?

TIA,
Douglas Wilson

Re: Templating system

Posted by Honza Pazdziora <ad...@informatics.muni.cz>.
On Thu, Jul 27, 2000 at 11:53:14AM -0700, Paul J. Lucas wrote:
> 
> 	1. I haven't had the time to figure out their submission
> 	   procedures.

The $CPAN/modules/04pause.html describes it in good detail. Namely,
write to modules@perl.org with the information listed.

> 	3. Although in practice it will most likely be used with Perl
> 	   or mod_perl, it's a stand-alone C++ library/API.

Some modules solve this by including the C/C++ code in the Perl
distribution (GD, XML::Parser), other only include the Perl code in
CPAN tgz's and the Makefile.PL links to preinstalled libraries
(Compress::Zlib). But having the module on CPAN helps people to find
the module. One of the strengths of Perl is that all you need and all
that is available you should be able to find on one place -- in ideal
world.

-- 
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
   .project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------

Re: [is it time for something other than html?] RE: Templating system

Posted by Barry Hoggard <ba...@investorama.com>.
We do what you describe with mason all of the time, since one can cache 
individual components on their own schedules.  If you look at:

http://www.investorama.com/guides/stocks

Everything above "you are here" isn't cached, except for "Who's online 
now", which is updated to show a number above a certain threshhold every 1 
minute.  "My Email" is updated every 3 minutes to show a flag if there's 
new mail.  The e-mail component is of course keyed to a specific individual 
when they're logged in.

The line that does this for mail is:

return if mc_cache_self(key => $ENV{REMOTE_USER}, expire_in=>'+3min');

The featured articles are updated once per day, as is the box with the 
number of our members that have "joined" this guide.  The number of people 
online that have joined the guide is updated every minute.

I could go on, but you get the idea.  The way mason works, the actual work 
is all done the first time a page or component is accessed, and is then 
stored using MLDBM.

At 12:22 PM 7/27/00 -0700, Jauder Ho wrote:

>...
>I could go off about why HTML sucks for dynamic page caching. If there was
>somehow a way to cache say the template, leaving only the same dynamic
>portion uncached, it would certainly help things along quite a bit. If
>anyone knows of a good way of doing this I would certainly be interested
>in hearing it.
>
>--Jauder



--
Barry Hoggard
VP of Software Development
e: barry@investorama.com
w: http://www.investorama.com


Re: [is it time for something other than html?] RE: Templating system

Posted by Joshua Chamas <jo...@chamas.com>.
Jauder Ho wrote:
> 
> the time/chance to implement such a system, it certainly looks like an
> interesting method of doing things. XML+XSLT is an interesting combination
> but integrating that into a dynamic generator (perl based or other) is
> going to be nontrivial to say the very least. Is there anyone interested
> in exploring this?
> 
> I could go off about why HTML sucks for dynamic page caching. If there was
> somehow a way to cache say the template, leaving only the same dynamic
> portion uncached, it would certainly help things along quite a bit. If
> anyone knows of a good way of doing this I would certainly be interested
> in hearing it.
> 

Apache::ASP lets you generate dynamic XML & XSL for cached 
XSLT rendering with XML::XSLT.  It also allows for custom 
taglibs specified with XMLSubsMatch.  Check out:

  http://www.nodeworks.com/asp/xml.html

Let me tell you, integration of XML::XSLT was non trivial,
especially the XML::DOM caching and output caching of 
XML::XSLT, for XSLTCacheSize.

Apache::ASP effectively compiles the static HTML into 
print() statements, and each page is compiled into a sub
which can be extremely fast with diligent use of 
Apache::ASP->Loader() for server startup precompilation,
so that all the pages run at sub {} execute speed.
These are common tricks shared by the sophisticated
templatting environments.

-- Joshua
_________________________________________________________________
Joshua Chamas			        Chamas Enterprises Inc.
NodeWorks >> free web link monitoring	Huntington Beach, CA  USA 
http://www.nodeworks.com                1-714-625-4051

Re: [is it time for something other than html?] RE: Templating system

Posted by Jauder Ho <ja...@carumba.com>.
Cool, I will definitely look further into this. Time to google...

--Jauder

On Thu, 27 Jul 2000, Kip Hampton wrote:

> Jauder Ho wrote:
> 
> <snip>
> > XML+XSLT is an interesting combination
> > but integrating that into a dynamic generator (perl based or other) is
> > going to be nontrivial to say the very least. Is there anyone interested
> > in exploring this?
> </snip>
> 
> Most of the hard work for this has been done by our own lovely and
> talented Matt Sergeant by providing native support for Perl XSP in
> AxKit. You add <myns:function param="stuff"/> to your XML and XSP does
> &function($param) and whatever else behind the scenes. Okay, so you have
> to write the taglib to make this happen, but once it's done it's done
> and you're *ML folks never have to deal with code at any level. And,
> while adding new taglibs is not exactly trivial, it certainly isn't
> rocket science, either.
> 
> IMHO, XML+yourfavoritetransformer(s) is the answer to separating the
> three worlds of code, content and design. Yes, we all want lighting
> fast, dynamic, reusable widgets for our Web apps. I'm just becoming
> increasingly convinced that HTML is one possible *output* of such a
> system, not it's basic building block.
> </soapbox>
> 
> -kip
> -- 
> "In this world you must be oh-so smart or oh-so pleasant.
>  Well, for years I was smart.... I recommend pleasant."
> 
>                                        --Elwood P. Dowd
> 
> 


Re: [is it time for something other than html?] RE: Templating system

Posted by Kip Hampton <kh...@totalcinema.com>.
Jauder Ho wrote:

<snip>
> XML+XSLT is an interesting combination
> but integrating that into a dynamic generator (perl based or other) is
> going to be nontrivial to say the very least. Is there anyone interested
> in exploring this?
</snip>

Most of the hard work for this has been done by our own lovely and
talented Matt Sergeant by providing native support for Perl XSP in
AxKit. You add <myns:function param="stuff"/> to your XML and XSP does
&function($param) and whatever else behind the scenes. Okay, so you have
to write the taglib to make this happen, but once it's done it's done
and you're *ML folks never have to deal with code at any level. And,
while adding new taglibs is not exactly trivial, it certainly isn't
rocket science, either.

IMHO, XML+yourfavoritetransformer(s) is the answer to separating the
three worlds of code, content and design. Yes, we all want lighting
fast, dynamic, reusable widgets for our Web apps. I'm just becoming
increasingly convinced that HTML is one possible *output* of such a
system, not it's basic building block.
</soapbox>

-kip
-- 
"In this world you must be oh-so smart or oh-so pleasant.
 Well, for years I was smart.... I recommend pleasant."

                                       --Elwood P. Dowd

Re: [is it time for something other than html?] RE: Templating system

Posted by Jauder Ho <ja...@carumba.com>.

Okay, I think there is still some confusion here as to what I am shooting
for. Ideally, I would like a system where the static parts of the page are
cached. I have recieved several mails suggesting that items such as the
header/footer can be turned into compiled print() statements as part of
the caching mechanism, but my concern is that 

a) You have to wait for it to generate the first time every time the
server is restarted. Granted, this is not too big of a deal. BlueMartini
(a product I was working with) is based on top of Weblogic and was so slow
that they had to create a tool to walk the tree to preload all the pages
into memory. Ugh.
b) HTML AFAIK only lets you set the pragma=no-cache on a per page level so 
the "static" portions of the page will not be cachable by systems such as
Inktomi's Traffic Server.

So essentially, what would be nice would be a system which is
cache-friendly (not server side) which at the same time is able to present
dynamic content. This I think would certainly help in the needless
representation of data that happens all the time today. 

Imagine, you go to a site with similar look and feel and once the
templates hit your browser, they can stay cached and only have the dynamic
bits fed to you. Faster surfing is good :)

--Jauder



On 28 Jul 2000, David Hodgkinson wrote:

> 
> Jauder Ho <ja...@carumba.com> writes:
> 
> > The template may be kept in memory but it needs to be reparsed to insert
> > real values, no? What I would like to see is a way to say the template is
> > static (header/footer) and does not need to be reparse/regenerated each
> > time and comparitively small portion of the page be dynamic. This way, you
> > can also store the html on the front end web server or akamize it and
> > concentrate on having the app servers provide only the actual data. 
> 
> If you want the resultant page to be cached, you can do this with a
> scary mod_rewrite mode.
> 
> -- 
> Dave Hodgkinson,                             http://www.hodgkinson.org
> Editor-in-chief, The Highway Star           http://www.deep-purple.com
>       Apache, mod_perl, MySQL, Sybase hired gun for, well, hire
>   -----------------------------------------------------------------
> 
> 


Re: [is it time for something other than html?] RE: Templating system

Posted by David Hodgkinson <da...@hodgkinson.org>.
Jauder Ho <ja...@carumba.com> writes:

> The template may be kept in memory but it needs to be reparsed to insert
> real values, no? What I would like to see is a way to say the template is
> static (header/footer) and does not need to be reparse/regenerated each
> time and comparitively small portion of the page be dynamic. This way, you
> can also store the html on the front end web server or akamize it and
> concentrate on having the app servers provide only the actual data. 

If you want the resultant page to be cached, you can do this with a
scary mod_rewrite mode.

-- 
Dave Hodgkinson,                             http://www.hodgkinson.org
Editor-in-chief, The Highway Star           http://www.deep-purple.com
      Apache, mod_perl, MySQL, Sybase hired gun for, well, hire
  -----------------------------------------------------------------

Re: [is it time for something other than html?] RE: Templating system

Posted by Perrin Harkins <pe...@primenet.com>.
On Thu, 27 Jul 2000, Jauder Ho wrote:
> The template may be kept in memory but it needs to be reparsed to
> insert real values, no?

No.  With most of these systems it turns into a bunch of "print" calls and
then into a bunch of perl opcodes, so it gets executed each time but not
parsed.

> What I would like to see is a way to say the template is static
> (header/footer) and does not need to be reparse/regenerated each time
> and comparitively small portion of the page be dynamic.

That's exactly what these do.  You can't really get faster than a compiled
print statement.

> This way, you can also store the html on the front end web server or
> akamize it and concentrate on having the app servers provide only the
> actual data.

Well, now you're talking about something different.  You could certainly
do that with a multi-server mod_perl setup, but the front end server would
have to be mod_perl and you would run the templating system there and then
make calls to another server that hands back some kind of data to be
inserted in it.  I've used this paradigm before.

- Perrin


Re: [is it time for something other than html?] RE: Templating s

Posted by jb...@team-linux.com.
On 27-Jul-2000 Jauder Ho wrote:
> 
> 
> The template may be kept in memory but it needs to be reparsed to insert
> real values, no? What I would like to see is a way to say the template is
> static (header/footer) and does not need to be reparse/regenerated each
> time and comparitively small portion of the page be dynamic. This way, you
> can also store the html on the front end web server or akamize it and
> concentrate on having the app servers provide only the actual data. 

The template does not have to reparsed every time. At least with Embperl, the
cached p-code is re-executed but that's it.

If you want to store headers and footers on a seperate machine and wrap them
around dynamic content take a look at my Apache::ProxyStuff module. It doesn't
cache the headers and footers but that feature would be quite easy to add.
 
> --Jauder
> 
> PS. I guess now that I think more about it, we can accomplish this with
> frames but that's a whole other story :)
> 
> On Thu, 27 Jul 2000, Perrin Harkins wrote:
> 
>> On Thu, 27 Jul 2000, Jauder Ho wrote:
>> > If there was somehow a way to cache say the template, leaving only the
>> > same dynamic portion uncached, it would certainly help things along
>> > quite a bit. If anyone knows of a good way of doing this I would
>> > certainly be interested in hearing it.
>> 
>> I believe every single one of the solutions discussed caches templates,
>> most of them as compiled perl code.
>> - Perrin
>> 
>> 

-- 
Jason Bodnar + jbodnar@team-linux.com + Team Linux

Weaseling out of things is important to learn.  It's what separates us
from the animals.  Except the weasel.

                -- Homer Simpson
                   Boy-Scoutz n the Hood


Re: [is it time for something other than html?] RE: Templating system

Posted by Jauder Ho <ja...@carumba.com>.

The template may be kept in memory but it needs to be reparsed to insert
real values, no? What I would like to see is a way to say the template is
static (header/footer) and does not need to be reparse/regenerated each
time and comparitively small portion of the page be dynamic. This way, you
can also store the html on the front end web server or akamize it and
concentrate on having the app servers provide only the actual data. 

--Jauder

PS. I guess now that I think more about it, we can accomplish this with
frames but that's a whole other story :)

On Thu, 27 Jul 2000, Perrin Harkins wrote:

> On Thu, 27 Jul 2000, Jauder Ho wrote:
> > If there was somehow a way to cache say the template, leaving only the
> > same dynamic portion uncached, it would certainly help things along
> > quite a bit. If anyone knows of a good way of doing this I would
> > certainly be interested in hearing it.
> 
> I believe every single one of the solutions discussed caches templates,
> most of them as compiled perl code.
> - Perrin
> 
> 


Re: [is it time for something other than html?] RE: Templating system

Posted by Perrin Harkins <pe...@primenet.com>.
On Thu, 27 Jul 2000, Jauder Ho wrote:
> If there was somehow a way to cache say the template, leaving only the
> same dynamic portion uncached, it would certainly help things along
> quite a bit. If anyone knows of a good way of doing this I would
> certainly be interested in hearing it.

I believe every single one of the solutions discussed caches templates,
most of them as compiled perl code.
- Perrin


RE: [is it time for something other than html?] RE: Templating s

Posted by jb...@team-linux.com.
On 27-Jul-2000 Jauder Ho wrote:
> 
> No. The problem is that you cannot cache the subsequent page that is
> generated because of the dynamic component. The template is always going
> to remain the same (interface changes should be rare for a stable web
> site), but the content (say news headlines or personalized component) is
> going to be dynamic. It is not reasonable to expect to cache that entire
> page. So what I am saying is that using HTML for such purposes is
> fundamentally broken unless we can figure out to tag a region of an html
> file as non-cachable i.e. dynamic. 

All the HTML is chached. Are you saying you want to cache everything including
the output of dynamic components? If so, then just stick squid in front of your
server.
 
> And as I replied to another reply about this, embedding code in a HTML
> file strikes me as an inelegant solution plus it leads to all sorts of
> problems such as html "designers" that delete tags for whatever reason. I
> know that the correct solution is to lart them but we can't always do that
> no matter how much we would like to :).

If you've got designers deleting tags then you need to educate them or fire
them. You cannot be flexible on that issue. Also, embedding code in HTML is no
different then putting arbitrary tags that some of the "templating" solutions
use. 

My last job was with Tivoli Systems and I used HTML::Embperl with great success
in several applications including ones that involved "designers" going in and
modifying pages with embedded perl code.

> On Thu, 27 Jul 2000 jbodnar@team-linux.com wrote:
> 
>> > I could go off about why HTML sucks for dynamic page caching. If there was
>> > somehow a way to cache say the template, leaving only the same dynamic
>> > portion uncached, it would certainly help things along quite a bit. If
>> > anyone knows of a good way of doing this I would certainly be interested
>> > in hearing it. 
>> 
>> There is. Use HTML::Embperl.
>> 
>> I've been using it for several years now. I build objects for accessing any
>> data I need and then do simple things in my templates like:
>> 
>> <H2>[+ $forum->title +]</H2>
>> 
>> -- 
>> Jason Bodnar + jbodnar@team-linux.com + Team Linux
>> 
>> If it'll make you feel any better, I've learned that life is one crushing
>> defeat after another until you just wish Flanders was dead.
>> 
>>                 -- Homer Simpson
>>                    Homer and Apu
>> 
>> 

-- 
Jason Bodnar + jbodnar@team-linux.com + Team Linux

Yeah, Moe, that team sure did suck last night!  They just plain
sucked!  I've seen teams suck before, but they were the suckiest bunch 
of sucks that ever sucked!

                -- Homer Simpson
                   Team Homer


RE: [is it time for something other than html?] RE: Templating s

Posted by Jauder Ho <ja...@carumba.com>.
No. The problem is that you cannot cache the subsequent page that is
generated because of the dynamic component. The template is always going
to remain the same (interface changes should be rare for a stable web
site), but the content (say news headlines or personalized component) is
going to be dynamic. It is not reasonable to expect to cache that entire
page. So what I am saying is that using HTML for such purposes is
fundamentally broken unless we can figure out to tag a region of an html
file as non-cachable i.e. dynamic. 

And as I replied to another reply about this, embedding code in a HTML
file strikes me as an inelegant solution plus it leads to all sorts of
problems such as html "designers" that delete tags for whatever reason. I
know that the correct solution is to lart them but we can't always do that
no matter how much we would like to :).

--Jauder

On Thu, 27 Jul 2000 jbodnar@team-linux.com wrote:

> > I could go off about why HTML sucks for dynamic page caching. If there was
> > somehow a way to cache say the template, leaving only the same dynamic
> > portion uncached, it would certainly help things along quite a bit. If
> > anyone knows of a good way of doing this I would certainly be interested
> > in hearing it. 
> 
> There is. Use HTML::Embperl.
> 
> I've been using it for several years now. I build objects for accessing any
> data I need and then do simple things in my templates like:
> 
> <H2>[+ $forum->title +]</H2>
> 
> -- 
> Jason Bodnar + jbodnar@team-linux.com + Team Linux
> 
> If it'll make you feel any better, I've learned that life is one crushing
> defeat after another until you just wish Flanders was dead.
> 
>                 -- Homer Simpson
>                    Homer and Apu
> 
> 


RE: [is it time for something other than html?] RE: Templating s

Posted by Kee Hinckley <na...@somewhere.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

>  >
>>  > <H2>[+ $forum->title +]</H2>
>>
>>	The problem with this is that it looks really ugly in
>  >	Dreamweaver (for example).

http://www.somewhere.com/software/ has the DreamWeaver extensions 
that will make EmbPerl tags look just like ASP or CFM tags, 
completely with the cute little graphics.
- -- 

Kee Hinckley - Somewhere.Com, LLC - Cyberspace Architects

I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.2 for non-commercial use <http://www.pgp.com>

iQA/AwUBOYGtiCZsPfdw+r2CEQKrXQCgiqHKAZv3NS2ZnsbilzwveQkRM5gAn0cH
dk8vp51MiPfmllRvgYEWtUsf
=dJHn
-----END PGP SIGNATURE-----

RE: [is it time for something other than html?] RE: Templating s

Posted by Gerald Richter <ri...@ecos.de>.
>
> > <H2>[+ $forum->title +]</H2>
>
> 	The problem with this is that it looks really ugly in
> 	Dreamweaver (for example).

That's a matter of taste...

And because it's a matter of taste (what is one of the results for me of
this discussion, everybody likes his aproach most :-), I have designed
Embperl 2 so, that you can define your own syntax, while don't have to
reinvent the rest.

Gerald


RE: [is it time for something other than html?] RE: Templating s

Posted by "Paul J. Lucas" <pj...@barefooters.org>.
On Thu, 27 Jul 2000 jbodnar@team-linux.com wrote:

> <H2>[+ $forum->title +]</H2>

	The problem with this is that it looks really ugly in
	Dreamweaver (for example).  The HTML designer can't design a
	mock-up page with dummy content using that technique that can
	then be passed off to the coder.

	With HTML Tree you can say:

	<H2 CLASS="text::forum_title">Recreational basketweaving</H2>

	i.e., put dummy content so the web page designer can see what a
	real page will look like and tweak things like spacing, etc.

	That HTML then can be used *as-is*, dummy content and all, with
	HTML Tree since the dummy content is replaced dynamically.

	- Paul


RE: [is it time for something other than html?] RE: Templating s

Posted by jb...@team-linux.com.
> I could go off about why HTML sucks for dynamic page caching. If there was
> somehow a way to cache say the template, leaving only the same dynamic
> portion uncached, it would certainly help things along quite a bit. If
> anyone knows of a good way of doing this I would certainly be interested
> in hearing it. 

There is. Use HTML::Embperl.

I've been using it for several years now. I build objects for accessing any
data I need and then do simple things in my templates like:

<H2>[+ $forum->title +]</H2>

-- 
Jason Bodnar + jbodnar@team-linux.com + Team Linux

If it'll make you feel any better, I've learned that life is one crushing
defeat after another until you just wish Flanders was dead.

                -- Homer Simpson
                   Homer and Apu


RE: [is it time for something other than html?] RE: Templating system

Posted by Gerald Richter <ri...@ecos.de>.
> > If there was somehow a way to cache say the template, leaving 
> only the same
> > dynamic portion uncached, it would certainly help things along 
> quite a bit.
> 
> 	An improvement to the technique used by HTML Tree is to
> 	"collapse" the non-dynamic portions of an HTML file into a
> 	single text node.  Given:
> 

Embperl 2.0 already does exactly this

Gerald


Re: [is it time for something other than html?] RE: Templating system

Posted by "Paul J. Lucas" <pj...@barefooters.org>.
On Thu, 27 Jul 2000, Jauder Ho wrote:

> If there was somehow a way to cache say the template, leaving only the same
> dynamic portion uncached, it would certainly help things along quite a bit.

	An improvement to the technique used by HTML Tree is to
	"collapse" the non-dynamic portions of an HTML file into a
	single text node.  Given:

		<H1>Heading</H1>
		This is ordinary content.
		It is <B>not</B> dynamic.
		This line, <SPAN CLASS="sub_word">however</SPAN>, is.

	You would ordinarily get:

		Element Node: <H1>
			Text Node: Heading
		Text Node:
			This is ordinary content.
			It is
			Element Node: <B>
				not
			Text node: dynamic.  This line,
			Element Node: <SPAN>
				Text Node: however
			Text Node: , is.

	But, since the bulk of that is static, the portains that do
	*not* contain elements having CLASS attributes could be
	"collapsed" so that you get:

		Text Node:
			<H1>Heading</H1>
			This is ordinary content.
			It is <B>not</B> dynamic.  This line,
			Element Node: <SPAN>
				Text Node: however
			Text Node: , is.

	i.e., the non-synamic HTML elements can be treated just like
	plain text and passed through untouched.  You could also devise
	a more complicated data structure that would cache such nodes
	separately.

	- Paul


[is it time for something other than html?] RE: Templating system

Posted by Jauder Ho <ja...@carumba.com>.
Watching this discussion has been very interesting, I am all for
separating the HTML and the code portions and have been unable to think of
a good solution to this particular problem. I ran across smartworker
(http://www.smartworker.org) a while ago and even though I have not had
the time/chance to implement such a system, it certainly looks like an
interesting method of doing things. XML+XSLT is an interesting combination
but integrating that into a dynamic generator (perl based or other) is
going to be nontrivial to say the very least. Is there anyone interested
in exploring this?

I could go off about why HTML sucks for dynamic page caching. If there was
somehow a way to cache say the template, leaving only the same dynamic
portion uncached, it would certainly help things along quite a bit. If
anyone knows of a good way of doing this I would certainly be interested
in hearing it. 

--Jauder


RE: Templating system

Posted by "Paul J. Lucas" <pj...@barefooters.org>.
On Thu, 27 Jul 2000, Douglas Wilson wrote:

> > > > 	http://www.best.com/~pjl/software/html_tree/
> 
> Is there a reason this is not on CPAN?

	The reasons (not necessarily good ones) are:

	1. I haven't had the time to figure out their submission
	   procedures.

	2. It's not (in my mind) in the "CPAN style" for the C++ part
	   of the build, i.e., you can't just say:

		perl Makefile.PL
		make

	   (You can say that for the Perl parts, however.)  The C++ part
	   doesn't require Perl at all.

	3. Although in practice it will most likely be used with Perl
	   or mod_perl, it's a stand-alone C++ library/API.

	- Paul


RE: Templating system

Posted by Douglas Wilson <do...@racesearch.com>.

> -----Original Message-----
> From: Paul J. Lucas [mailto:pjl@barefooters.org]
> Sent: Thursday, July 27, 2000 10:11 AM
> To: modperl@apache.org
> Subject: Re: Templating system
> 
> 
> On Thu, 27 Jul 2000, Jeffrey W. Baker wrote:
> 
> > On Thu, 27 Jul 2000, Paul J. Lucas wrote:
> > 
> > > 	http://www.best.com/~pjl/software/html_tree/

Is there a reason this is not on CPAN? It would have been
nice to come up in a search. (I actually searched for 'template',
so I'm not sure I would have ever found it anyway :)

Cheers,
Douglas Wilson

Re: Templating system

Posted by "Paul J. Lucas" <pj...@barefooters.org>.
On Thu, 27 Jul 2000, Jeffrey W. Baker wrote:

> On Thu, 27 Jul 2000, Paul J. Lucas wrote:
> 
> > 	http://www.best.com/~pjl/software/html_tree/
> 
> Hey, that's really nice.

	Thanks.  :)  Admitedly, the web site could use more example
	other than what's in the manual pages, but where, oh where, to
	find the time...

> And once the template HTML files are parsed, I can just leave the $root_node
> in memory for future requests, right?

	Yes, I suppose so...  I never thought hard about doing that.
	The reason is that you have to be careful about doing it since
	the Perl/mod_perl API *intends* for you to manipulate/change
	the structure/content, hence what you're left with after a page
	generation is not the same HTML tree you started with.

	The HTML DOM parsing is really fast since that part of the
	software is written natively in C++ with memory-mapped I/O.
	(It's the same parsing engine used in SWISH++, FWIW.)

	HTML Tree does, however, cache the associated Perl (.pm) code
	for a page just like Apache::Registry does (based on timestamp).

> And since the parser isn't validating, I can extend HTML with tags like
> <NODE>, <BANNER>, and <WHATEVER>, right?

	Not really, actually.  The reason is that the HTML parser
	doesn't know anything about non-standard HTML elements so it
	can't know if an element (not "tag") you make up has a required
	or optional end tag to get the parsing ("balancing") right.  If
	this were XML, it would be a different story.

	Currently, "made up" elements are ignored entirely, i.e., *not*
	added to the resultant HTML DOM tree and do not affect
	"balancing" during parsing.

	- Paul


Re: [OT]: GPL (Was: Templating system)

Posted by Alex Farber <fa...@cpan.org>.
"Paul J. Lucas" wrote:
> > The ability to build commercial applications.
> 
>         The GPL allows you to use and incorporate GPL'd software into
>         commercial applications.  However, if you *modify* the GPL'd
>         software, you *must* make said modifications freely available
>         under the GPL also.  If you don't modify it, there is no issue.

That's wrong: GPL regulates software distribution only.
If you modify a GPL-program for internal use, you don't
have to distribute your changes.

Regards
Alex

--
Suche eine UNIX-Stelle ab September:
http://www.kawo2.rwth-aachen.de/~alex/

[OT]: GPL (Was: Templating system)

Posted by "Paul J. Lucas" <pj...@barefooters.org>.
On Thu, 27 Jul 2000, Matt Sergeant wrote:

> I wrote:
> > 	What's wrong with the GPL?  It's open-source and free of cost.
> > 	What more do you want?
> 
> The ability to build commercial applications.

	The GPL allows you to use and incorporate GPL'd software into
	commercial applications.  However, if you *modify* the GPL'd
	software, you *must* make said modifications freely available
	under the GPL also.  If you don't modify it, there is no issue.

	Also, just because a piece of code is GPL'd does *not* preclude
	the author from granting *separate* commercial licenses.  As
	the author for HTML Tree, I can grant as many any additional
	licenses under any terms I please.

	For example, if you wanted to use HTML Tree *and* make
	*proprietary* modifications, I'd be happy to charge you a
	licensing fee.  However, again, merely *using* GPL'd software
	*as-is* requires so such additional license.

	Please re-read the GPL.  FYI: I've also had correspondence with
	the FSF on such issues and the above is correct.

	- Paul


Re: Templating system

Posted by Matt Sergeant <ma...@sergeant.org>.
On Thu, 27 Jul 2000, Paul J. Lucas wrote:

> On Thu, 27 Jul 2000, Matt Sergeant wrote:
> 
> > > > 	http://www.best.com/~pjl/software/html_tree/
> 
> > Aside from the GPL, it does looks nice.
> 
> 	What's wrong with the GPL?  It's open-source and free of cost.
> 	What more do you want?

The ability to build commercial applications.

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org | AxKit: http://axkit.org


Re: Templating system

Posted by Ask Bjoern Hansen <as...@valueclick.com>.
On Thu, 27 Jul 2000, Paul J. Lucas wrote:

> On Thu, 27 Jul 2000, Matt Sergeant wrote:
> 
> > > > 	http://www.best.com/~pjl/software/html_tree/
> 
> > Aside from the GPL, it does looks nice.
> 
> 	What's wrong with the GPL?  It's open-source and free of cost.
> 	What more do you want?

the ability to use and modify it freely, like you can do with Perl,
Apache and FreeBSD.


 - ask

-- 
ask bjoern hansen - <http://www.netcetera.dk/~ask/>
more than 70M impressions per day, <http://valueclick.com>


Re: Templating system

Posted by "Paul J. Lucas" <pj...@barefooters.org>.
On Thu, 27 Jul 2000, Matt Sergeant wrote:

> > > 	http://www.best.com/~pjl/software/html_tree/

> Aside from the GPL, it does looks nice.

	What's wrong with the GPL?  It's open-source and free of cost.
	What more do you want?

	- Paul


Re: Templating system

Posted by Matt Sergeant <ma...@sergeant.org>.
On Thu, 27 Jul 2000, Jeffrey W. Baker wrote:

> On Thu, 27 Jul 2000, Paul J. Lucas wrote:
> 
> > On Thu, 27 Jul 2000, Darko Krizic wrote:
> > 
> > > I want to write a new application using mod_perl but this time I want to
> > > completely divide the code from the HTML. Therefore I am seeking for a
> > > powerfull and fast templating system.
> > 
> > 	http://www.best.com/~pjl/software/html_tree/
> > 
> > 	It does precisely what you're asking.
> 
> Hey, that's really nice.  And once the template HTML files are parsed, I
> can just leave the $root_node in memory for future requests, right?  ANd
> since the parser isn't validating, I can extend HTML with tags like
> <NODE>, <BANNER>, and <WHATEVER>, right?
> 
> Pant, pant.

Aside from the GPL, it does looks nice.

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org | AxKit: http://axkit.org



Re: Templating system

Posted by "Jeffrey W. Baker" <jw...@acm.org>.
On Thu, 27 Jul 2000, Paul J. Lucas wrote:

> On Thu, 27 Jul 2000, Darko Krizic wrote:
> 
> > I want to write a new application using mod_perl but this time I want to
> > completely divide the code from the HTML. Therefore I am seeking for a
> > powerfull and fast templating system.
> 
> 	http://www.best.com/~pjl/software/html_tree/
> 
> 	It does precisely what you're asking.

Hey, that's really nice.  And once the template HTML files are parsed, I
can just leave the $root_node in memory for future requests, right?  ANd
since the parser isn't validating, I can extend HTML with tags like
<NODE>, <BANNER>, and <WHATEVER>, right?

Pant, pant.

-jwb


Re: Templating system

Posted by "Paul J. Lucas" <pj...@barefooters.org>.
On Thu, 27 Jul 2000, Darko Krizic wrote:

> I want to write a new application using mod_perl but this time I want to
> completely divide the code from the HTML. Therefore I am seeking for a
> powerfull and fast templating system.

	http://www.best.com/~pjl/software/html_tree/

	It does precisely what you're asking.

	- Paul


Re: Templating system

Posted by Matt Sergeant <ma...@sergeant.org>.
On Thu, 27 Jul 2000, Jeffrey W. Baker wrote:

> > 
> > No, but I was thinking of incorporating enhydra's XMLC technology into
> > AxKit. I'm not sure its a better method of working than XSLT or
> > XPathScript though, which allows you to be future looking (always
> > XML). But it could be kinda neat to do. Should be almost trivial with
> > HTML::Parser to generate perl out of that. Providing of course they don't
> > have some stupid patent on it (doubtful since its GPL'd).
> 
> Has anybody looked at transformiix for doing these xslt transforms?  It is
> an XSLT processor with an API.  It requires expat.

I'm aware of transformix, but I'm no XS wizz (just did my first bit of XS
programming yesterday, actually, and that was 99% cut/paste), so someone
else would have to do a module for it. Of course Sablotron
(www.gingerall.com) has a step ahead of them there - they already have a
Perl module (although Sablotron isn't as close to the complete XSLT spec
as transformix, AFAIK).

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org | AxKit: http://axkit.org


Re: Templating system

Posted by "Jeffrey W. Baker" <jw...@acm.org>.
On Thu, 27 Jul 2000, Matt Sergeant wrote:

> On Thu, 27 Jul 2000, Darko Krizic wrote:
> 
> > I want to write a new application using mod_perl but this time I want to
> > completely divide the code from the HTML. Therefore I am seeking for a
> > powerfull and fast templating system.
> > 
> > Newly I did something with Enhydra (Java Servlets) and they have a pretty
> > neat templating system: They use standard HTML and one uses the "id"
> > attribute in HTML tags to access them and manipulate values/contents. For
> > example:
> > 
> > <table id="results">
> > 	<tr id="resultheader">
> > 		<th>Name</th>
> > 		<th>Count</th>
> > 	</tr>
> > 	<tr id="singlerow>
> > 		<td id="row_name">example name</td>
> > 		<td id="row_count">example count</td>
> > 	</tr>
> > </table>
> > 
> > The program now can repeat the tr "singlerow" for each table row and insert
> > it under the tr "resultheader". The values can be inserted into the tds
> > "row_name" and "row_count". The main advantage is: The designer can generate
> > HTML pages that can be viewed with a standard browser.
> > 
> > Does anybody know something similar for Perl?
> 
> No, but I was thinking of incorporating enhydra's XMLC technology into
> AxKit. I'm not sure its a better method of working than XSLT or
> XPathScript though, which allows you to be future looking (always
> XML). But it could be kinda neat to do. Should be almost trivial with
> HTML::Parser to generate perl out of that. Providing of course they don't
> have some stupid patent on it (doubtful since its GPL'd).

Has anybody looked at transformiix for doing these xslt transforms?  It is
an XSLT processor with an API.  It requires expat.

http://lxr.mozilla.org/mozilla/source/extensions/transformiix/docs/readme.html

-jwb


Re: Templating system

Posted by Matt Sergeant <ma...@sergeant.org>.
On Thu, 27 Jul 2000, Darko Krizic wrote:

> I want to write a new application using mod_perl but this time I want to
> completely divide the code from the HTML. Therefore I am seeking for a
> powerfull and fast templating system.
> 
> Newly I did something with Enhydra (Java Servlets) and they have a pretty
> neat templating system: They use standard HTML and one uses the "id"
> attribute in HTML tags to access them and manipulate values/contents. For
> example:
> 
> <table id="results">
> 	<tr id="resultheader">
> 		<th>Name</th>
> 		<th>Count</th>
> 	</tr>
> 	<tr id="singlerow>
> 		<td id="row_name">example name</td>
> 		<td id="row_count">example count</td>
> 	</tr>
> </table>
> 
> The program now can repeat the tr "singlerow" for each table row and insert
> it under the tr "resultheader". The values can be inserted into the tds
> "row_name" and "row_count". The main advantage is: The designer can generate
> HTML pages that can be viewed with a standard browser.
> 
> Does anybody know something similar for Perl?

No, but I was thinking of incorporating enhydra's XMLC technology into
AxKit. I'm not sure its a better method of working than XSLT or
XPathScript though, which allows you to be future looking (always
XML). But it could be kinda neat to do. Should be almost trivial with
HTML::Parser to generate perl out of that. Providing of course they don't
have some stupid patent on it (doubtful since its GPL'd).

Can you wait, or do you need something now?

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org | AxKit: http://axkit.org