httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dirk-Willem van Gulik <dirk.vangu...@jrc.it>
Subject Templates and XML - Provoking to get Help !
Date Fri, 20 Nov 1998 15:33:11 GMT

Most of you might have seen the Servlet related project:
	
	http://www.webmacro.com/docs/QuickStart.html

and also recall the discussion on a general way of doing templates. I
think this was started by Brian.

Now one day, something like an apache deamon with layered IO might arrise.
That would mean you could do really cool templates and i18n :-) This is
just a fluff email to get some comments.

I'am trying to take an early start and am working on a project where we
really want to split code form content; and even worse have multilingual
content to ship out....

The 'solution' seems to build a content structure (with a lot of variant
fields where needed) and pass that to a template engine. Which has some
discreation in which templates to pull in:

cgi/mod_perl -> content-structure -> template engine -> html -> client
                      ||                   |||
		XML or in 'perl'           |||
                                         /  |  \
				templates, recursive and in
				different flavours; depeding
				on browser agent and accept language

Where the latter ideally lives in a mod_ module, but is a piece of perl
at the moment. Which works. And seems to do meet my requirements with
just a bit of the WebMacro language (which is a bitch to parse :-().

So I am feeding it things like

	<title lang="en">Hello World</title>
	<title lang="nl">Nu dag dan</title>
	<item name="customer" lang="en">
		<name lang="en">Jan</>
		<owing>123</>
		</>
	<item name="customer" lang="en">
                <name>Piet</>    
                <owing>123</>
                </>
	
Where I am doing simple 'if an intem exists, then it must be an array' and
if it has any attributes, such as 'lang' then they must be hashed in
paralel to it. I agree that the above structure is no beauty. Just work
in progress.

This translates to perl (or C, C++, Java ...) structures like

	$VAR1=
	{	title => (
			lang => (
				'en' => 'Hello World',
				'nl' => 'Nu dag dan'
				)
			),
		customer => [
			{
				name => (
					lang => (
						'en' => 'Jan'
						)
					),
				owing => 123
				},
			{
				name => 'Piet',
				owning=> 123
				}
			];
	}

Actually you should ignore the XML, it is the perl strucutre
that counts.

Now currently the WebMacro module supports just the following:

           <ul>
           #foreach $customer in $customerList
           {
                   <li> $customer.name owes $customer.owing
           }
           </ul>
           
           #if ($variable) {
              Yes we have variable: $variable
           } else {
              Sorry, variable is not defined here
           }

           #include "someUnparsedFile.txt" 

           #set $variable = value 

           #parse "includeSomeWebMacroTemplate.wm" 

           #include "$variableFile" 

           #script 'unparsed' boundary="--The End--"
           Text here is not parsed by WebMacro, up until the
           line matching the supplied boundary.
            --The End--

And this seems reasonably complete and straightforward. What I'd like to
see is get a bit of discussion of how much more would be needed in the 
above language to accomplish

	1. code separation form content

	2. allow for mixing languages such as perl, python, php serverside

	3. with embedded code in the page

	4. with some choise of running it on the server

and most importantly

	5. having variants for languages, charsets, ....

Think of your pet project.. and imagine how far this would fly.. or just
flame me for trying to give a pig sufficient trust. On the other hand, you
might be around when it lands.

Dw


Mime
View raw message