I am deeply frustrated about the situation of all these template modules. There are MANY to choose from, but not one of them are complete enough!!! I would like to see a joint effort to a common platform ------------------------------------------------------- This mail has gotten rather big. I don't want to add to it more and more. I just want to coordinate things to get ONE good module. I am very close to write it myself. I would take Text::MetaText as a base, but add all the features and interfaces from all other modules. I have used templates for some years now. The importent thing was to separate the data from the design. The design could be created by a designer/maintainer in a regular HTML editor and it would be used by the CGI program. There is another class of tempaltes that mixes perl into the HTML source in a way similar to javascript. Thats not the way I want it. The non-programmer designer will start editing the page in his favorite HTML editor and do not want to se the code. The interface to the data should be as clean and simple as possible. If you mix a lot of perl in the HTML documents, you could do fine with regular CGI programs with big "print <[* my_var1 *] [* my_var2 *] [* ENDREPEAT *] This would produce a method call like: $self->My_Function( { name1 => 'value1', name2 => 'value2' } ); And the method could look like this: sub My_Function { my( $self, $data ) = @_; # Do something with $data to produce: my $res = [ { 'my_var1' => 'R1C1', 'my_var2' => 'R1C2' }, { 'my_var1' => 'R2C1', 'my_var2' => 'R2C2' }, { 'my_var1' => 'R2C1', 'my_var2' => 'R3C2' }, ]; return $res; } And that would produce: R1C1 R1C2 R2C1 R2C2 R3C1 R3C2 Output filters -------------- The filters should be simple methods. Modules ======= CGI::FastTemplate ----------------- Value: $value HTML::Subtext ------------- Value: Author's name here And this will replace the whole link with the value for "author/name". You shouldn't have to give up all the functionality of the other modules to use this type of markup. HTML::Template -------------- Value: Repeat: Name:

Job:

Text::BasicTemplate ------------------- Value: %VALUE% Conditional: %VALUE=Text%Text if true%Text if false% Text::Boilerplate ----------------- In Text::Boilerplate, each tag is its own class in an special hierarchy. But the process to add new tags is not documented. Value: [* "Value" *] Conditional: [* IF NAME="Items Found" *] [* "Items Found" *] items were found. [* ELSE *] No items were found. [* /ELSE *] [* /IF *] Repeat: [* REPEAT NAME="User List" *]

  • [* "Username" *] [* /REPEAT *] '[*' and '*]' can be changed to something else. The repeat example above vill be filled with a data structure like: { 'User List' => [ { 'Username' => 'jonas', }, { 'Username' => 'bosse', }, ], } The problem with the design is that all values hs to be set up in structures like this. If the template doesn't even have a "User List", the list is a vaste. You should be able to specify a SQL statement in the template that will generate a structure like the above, with all the returned rows. Text::Bind ---------- Include file: ##PL_file=copyright.html## Value: ##PL_site=inputform## The site could be eiter a value or a function: $text->bind_site("astring", "Hello World!"); $text->bind_site("form", \&generate_form); This module permit unsecure things like: ##PL_file=/bin/ls -l |## Text::Fillin ------------ A tag could be created like this: sub TExport::add_numbers { my $result; foreach (@_) { $result += $_; } return $result; } And would be called with: [[&add_numbers(3,.1,.04,.001,.0006)]] Value: [[$value]] Function: [[&function]] The '[[' and ']]' can be changed. Here, it is the '$' that is the actual tag, that could have been defined with: Text::FillIn->hook('$', sub { return ${$_[0]} }); # Hard reference This is enough to implement file includes and conditionals. But not iterations (in a simple way). Text::Merge ----------- Text::Merge let you specify hooks to functions. But you can't pass input parameters to them from the template. Value: [[REF:Value:formats]] Function: [[ACT:Function:formats]] Conditional: [[IF:FieldName:formats{Text to display}]] The '[[' and ']]' could be leaved out, but not replaced by something else. The REF, ACT, etc are predefined. This module have a speciel way to fill in text around its value, only if the value is true: The {quick }REF:Animal{ jumps the }lazy dog lies. It also has a lot of filters for the values, that can be specified in the template: REF:Animal:lower:trunc3 would result in the first three letters of the SCALAR data value associated with Animal in lower case. Text::MetaText -------------- In Text::MetaText, you will subclass the module with your own methods. A markup like this: %% foo name="Seuss" title="Dr" %% would generate this call: $self->foo( # implicit $self ref { 'name' => 'Seuss', 'title' => 'Dr' }, # hash ref of params 'name="Seuss" title="Dr"' ); # parameter string %% INCLUDE file_or_block # include block or external file variable = value # additional variable definition(s) if = condition # conditional inclusion unless = condition # conditional exclusion format = format_string # printf-like format string with '%s' filter = fltname(params) # post-process filter %% '%%' and '%%' can be changed to something else. INCLUDE is one of several predefined tags. You can subclass the module and create other tags. It is possible, but ugly, to create a REPEAT tag. Who could be intrested in this? DbFramework - Paul Sharpe DBIx::CGI - Stefan Hornburg DBIx::HTMLView - Hakan Ardo Text::BasicTemplate - Devin Carraway Text::Boilerplate - Steve Nelson Text::Bind - Earl Hood Text::FillIn - Ken Williams Text::Merge - Steve Harris Text::MetaText - Andy Wardley HTML::Subtext - Kaelin Colclasure HTML::Template - Sam Tregar Text::Template - Mark-Jason Dominus HTML::Embperl - Gerald Richter HTML::EP - Jochen Wiedmann HTML::Mason - Jonathan Swartz Parse::RecDescent - Damian Conway Text::EP3 - Gary Spivey Text::Vpp - Dominique Dumont CGI::FastTemplate - Jason Moore