[Catalyst-dev] Catalyst plugin

Octavian Rasnita orasnita at gmail.com
Thu Oct 2 17:35:20 BST 2008


From: "Tomas Doran" <bobtfish at bobtfish.net>

>> Yes. I have previously asked the author of Mail::Builder if he  thinks it 
>> is a good idea to create Mail::Builder::Simple and he  said yes. He also 
>> recommended me to name the module that uses TT 
>> Mail::Builder::Simple::TT.
>> But as I said, I want to change some things for making the module  able 
>> to use other templating systems.
>>
>
> Ok, so you're all sorted on that front then?

Well, not exactly. I know what I want to do, but I don't know exactly how.

Until now, I had a Mail::Builder::Simple that creates the message and sends 
it using Email::Send.
And I also had a wrapper Mail::Builder::Simple::TT that uses 
Mail::Builder::Simple and Template-Toolkit for creating the parts that use 
templates.

So in the Catalyst module I wanted to use Mail::Builder::Simple::TT for 
beeing able to interpret templates if the user needs that, but it is not 
well, because maybe some templates use Mason or HTML::Template.

So now I want to make somehow the base modules in such a way so I need to 
access Mail::Builder::Simple only, and if this module will see that the user 
uses a template, it should require Mail::Builder::Simple::TT or 
Mail::Builder::Simple::Mason or another one.
And if somebody will want, he could create another module 
Mail::Builder::Simple::AnotherTemplate.

I could get a way of doing this, but I would like to do it as clean as 
possible, for example if I will find that a template uses TT, 
Mail::Builder::Simple should require Mail::Builder::Simple::TT with the 
default options, but it would be nice to load the ::TT module only if it 
finds that it needs it for parsing a TT template, and it would be also nice 
if it would create the $template object only once if possible, for a better 
speed.

And if I would send a mail message to many email addresses, it would be also 
nice if the message would be created only once, or at least the parts of the 
message which are not modified for each receiver.

> If you're building an email module which is external to Catalyst and  just 
> glued in as a model (which sounds like a pretty good approach),  then I 
> don't think you're going to get to share code with  C::V::Email, but (as 
> discussed above), you're already going to be  using/re-using several other 
> modules, so it's all good..

That's what I was thinking but I couldn't express it very well.

Thank you for your help and suggestions.
The model-way looks pretty clean and I will try to use this way.

Octavian




More information about the Catalyst-dev mailing list