[Dbix-class] InflateColumn::Markup::Unified inflates columns that use a markup language

Bernhard Graf dbic4 at augensalat.de
Wed Sep 30 07:35:03 GMT 2009


Ido Perelmutter schrieb:

> Two modules I've created: Markup::Unified and
> DBIx::Class::InflateColumn::Markup::Unified are now on CPAN. The first
> one was written just to facilitate the second one. What I wanted here
> was a way to automatically process text columns that use one of the
> three popular markup languages Textile, Markdown and BBCode.
> 
> So, if you have, for example, a database with a comments table, where
> comment text is written in Textile syntax, then DBIx::Class will
> automatically process the text into HTML. Not only that, you don't even
> have to enforce just one markup language on a column, and allow all
> three. This is useful, for example, if you want to allow the users who
> comment to do so with their preferred markup language.
> 
> Anyway, I'd really like to get any ideas, suggestions and complaints you
> may have. If you want support for another markup language, I'll be glad
> to add it.

OK, here is mine:

Even though I appreciate every effort for DBIC, I wouldn't use your
module, because it breaks the widely adopted MVC paradigm by doing the
formatting in the model. What if I wanted my output in PDF, for example?

To play nicely with MVC systems, your module should transform any of the
supported markup codes into some common abstract object instance.
The task of formatting that object belongs to the view.

Since none of the existing (e.g. Catalyst) View classes yet support such
an abstract markup object (and I bet none ever will), you - or anyone -
could write formatters for popular formats, e.g.
Markup::Unified::Formatter::HTML, Markup::Unified::Formatter::PDF etc.

That's very much the way how DateTime works, btw.

Bernhard



More information about the DBIx-Class mailing list