You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Jauder Ho <ja...@carumba.com> on 2000/07/27 21:22:26 UTC

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

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: [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