new templates module, beginners questions

2000-12-08 Thread Andreas Jaekel

Hi!

I've just written a module for our internal use and would like to
contribute it to CPAN. It's my first contribution (as opposed to "my
first module") so I am uncertain and have questions. Please help me.

My module was meant to replace CGI::FastTemplate, which we used before.
It's advantages are
 o real OO-perl, meaning instances actually keep _seperate_ data
 o template search (automated file tree traversing if a file is not found)
 o callback registration for markers
 o callback registration for error handling
 o more caching options (optional mtime check, max cache-size)
 o parsing of strings _and_ files, not only filesand most of all:
 o a much easier interface.

It's disadvantages are
 o it's slower.

I have found out that there are various template modules on CPAN
already. I admit that this search came a little late :)

However, my module is complete, tested by me and documented, and
it has some features that others do not have. (except maybe for the
Template:: bundle, which is a little hard to "have a look into".
I expect an O'Reilly book about it any day now)

My questions are:
 o should I upload this module? Considering the other template modules,
   some of it's features are already on CPAN. But then, a general-purpose
   caching template module with callbacks, error handling and directory
   traversing/template autoload is a combination I haven't found yet.

 o what namespace should I use, if I should upload it? Currently, the
   module is named SaneTemplates. (I started writing it because the
   syntax and interface of CGI::FastTemplate drove me crazy. Why
   would I 'define' a template prior to use if I could just use it right
   away? Why use the ambigous assign(a => b)? This actually assigns b
   to a. Hooray.  set(a => b) or $tpl->{a} = b  is much better.)

   However, since both CGI::FastTemplate and my module are not HTML, CGI
   or even text-file specific I think the CGI-namespace would be
   inappropriate.

 o Is there a demo-module on CPAN that tells me what Makefile.PL and
   the test scripts should look like? Why is this demo module not mentioned
   on the web site or the contributers part of the FAQ?


If you have any questions, please write me mail. If you think
a look at the source could help, the module is currently available at
  http://www.furry.de/tabalon/SaneTemplates.pm
I have documented the module in POD format within the source.

Should any of you take the time to read the source, any comment is
greatly appreciated.

Greetings and thanks,
   Andy

-- 
Andreas Jaekel, CableCats - Foest, Jaekel, Tegethoff GbR
http://www.cablecats.de  Tel.: 030 - 916 11 77 3



Re: new templates module, beginners questions

2000-12-11 Thread Andreas Jaekel

Hi Johan,

> Please do! If your module indeed is easier to use people will like it.

I hope so :) In that case, I'd like to register. The PAUSE FAQ says
I should do so here. So here it comes:


Name: Andreas Jaekel
eMail   : [EMAIL PROTECTED]
Homepage: http://www.furry.de/tabalon
UserID  : AJAEKEL

About this module:

Desc: a general-purpose caching template module with callbacks, error 
  handling and directory traversing/template autoload
DSLI: RdpO templates with cache, callbacks and autoload

This module was not discussed in public. It is the result of our group's
internal expirience and discontentment with the CGI::FastTemplate module.
We have collected ideas for a better API and some new features. I've
implemented and tested it and it looks good. 

The reasons we don't like the old API are:
 o You have to 'define' a template before using it:
$tpl->define( a => a.tpl );
$tpl->parse( A => a );
 o You can't parse a string. Only a template file.
 o You assign values to markers. We could never remember the syntax 
   because $tpl->assign( A => B );  assigns the value B to the marker A. :(
   The new module uses $tpl->set( A => B ); or $tpl->set( A, B ) or
   $tpl->{A} = B;
 o $tpl->parse( RESULT => a ) doesn't return the parsed document. You can
   only use $tpl->fetch( RESULT ) to get the data.
 o CGI::FastTemplates mixes the data between instances if you have more
   than one.



> >  o what namespace should I use, ... However, since both
> 
> Template:: ?

Well, Template:: is already given. It's a whole toolkit by Andy Wardley (ABW)
and the 2.00 final release was five days ago :)  It's available from
http://www.template-toolkit.org/ (*grin*) and seems to be _very_ complete.

I've just read through the documentation, and I think the Template::
toolkit is the definitve solution for all template needs. It might
even be a little over-engineered.

So why would anyone want to use my module? Some reasons I see:
 o it's small (650 lines or so)
 o it might be faster than Template.pm, but would be slower than
   CGI::FastTemplate
 o it allows no logic in the templates (loop, if/then/else) which I think
   is an advantage. (try working with designers on one project and stop
   them from using all possible bells and whistles. Good luck.)
 o it's easier to use since the whole documentation has only 12 pages
   (pod2man | nroff) including many examples.
 o it has template autoloading included.


Is that enough to justify yet another template module on CPAN?

And again, what namepsace would I use? :)


> I'm afraid there is no such module (yet?). When you use h2xs to
> generate the stubs it will provide templates for the tests and
> Makefile.PL as well. I can send you some samples, if you like.

This works just fine. Thanks! And to Tels, too, who sent me the
same hint.


Greetings,
   Andy

-- 
Andreas Jaekel, CableCats - Foest, Jaekel, Tegethoff GbR
http://www.cablecats.de  Tel.: 030 - 916 11 77 3