ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl6-language
perl6-language
Creating a web templating engine
by B=C1RTH=C1ZI_Andr=E1s other posts by this author
Jun 14 2005 8:59AM messages near this date
Re: Creating a web templating engine | Re: new mailing list: perl6-general?
Hi,

I'm busy with creating a widget based web templating engine, but I have 
some problems, please help me. The engine would allow you to define 
widgets, and use those in your templates. I would like it to be an OO 
module.

In the template, you can write this:

  <server:input id="name" width="100px" maxlength="64" important="yes" /> 

When the template engine read it, it will call a subroutine:

  call_a_sub_for_input(id=> 'name', width=>'100px', maxlength=>'64',
                       important=> 'yes');

What this sub gives back, will be put into the output. I hope, you got the 
idea.

I have the code, that can parse the template, and the code, that would 
call the widget, so no problems with it. I don't know, how to put it 
together. I don't know, how should the programmer define a new widget, 
how it would be the most nicer way? How it can be detected by the template 
engine? I don't want a register function, like this:

$wte = new WTE;
$wte.register('input', &my_input_widget);

I don't prefer it, to be 20-30 register line in my programs, that does 
nothing, just register.

It would be OK, to just define a global subroutine, and allow the template 
engine to call widget_$name if it reads a widget, but...

sub widget_input(*%params) {
 	...
}

It's not nice. Maybe something like this?

new_widget :input =>  {
 	return "<input /> ";
}

It's almost a register function, but it's more compact, and I like it. But 
if I would like to get parameters from the widget caller, how can I manage 
it? Is it possible to call this new noname sub with parameters, and get it 
easily inside the sub, for example like this:?

new_widget :input =>  {
 	my $name = _something_{'id'};
 	return '<input name="' ~ $name ~ '" /> ';
}

And I have more questions, but that's enough for this mail. Did you got my 
problem?

Bye,
   Andras

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved