[Catalyst] To plugin or not to plugin; style/best-practices

apv apv at sedition.com
Wed Dec 14 01:40:52 CET 2005


On Tuesday, December 13, 2005, at 04:34  PM, Matt S Trout wrote:
> On Tue, Dec 13, 2005 at 04:10:52PM -0800, apv wrote:
>> I'm working on a user supplied comment. I want to apply some auto
>> formatting to it (paras but with somewhat complicated rules for where
>> they go, no simple splitting on "\n\n," so it's not going to be very
>> compact code) in addition to HTML sanitizing.
>>
>> Should this be a plugin or a controller? If a plugin makes sense, is
>> there one already out there I should look at for good learning code?
>
> Sounds like view logic to me :)
I rather agree in part but it's information that is going into the DB 
as opposed
to--directly, anyway--the screen. So, the data (html) should be 
transformed before
it ever gets sent to TT. I don't want to reprocess it every time. I 
think. I
can see advantages to that because it would be the same format to the
user. But then I think you end up running into legacy issues when making
changes down the road, having to support things you wish you could just
flush. But it's definitely something to think about.
>
> I'd suggest building it as a Template Toolkit filter, assuming that's
> what you're using for the rendering - have a look at the appropriate 
> bits
> of Template::Manual::Directives and ::Config and the Template::Context
> API for details.
I've written a few simple TT filters in the past and this might indeed 
be
a good way to go.

I can put the transform code into the View space anyway and just forward
to it when taking user text. Does that seem sound?




More information about the Catalyst mailing list