Re: [Maypole] text formatting

From: Dave Howorth (dhoworth at mrc-lmb.cam.ac.uk)
Date: Tue Nov 02 2004 - 10:02:19 GMT


I wrote:
> I have a question about text formatting in Maypole. If the value of a
> field in the database is text in which the spaces and especially line
> breaks are significant, how is it handled by Maypole?

Simon Cozens replied:
> It isn't handled. That's a templating issue. Maypole doesn't really
> care what you display, whether it's HTML, plain text, or whatever.
> That's not part of its remit.

> No, you just need to change your templates from, say,
> [% beer.description %]
> to
> [% beer.description | html_line_break %]
>
> You are using your own custom templates, aren't you?

Well, no, I'm not yet. The issue that occurs to me with regard to your
suggestion is m*n complexity versus m+n. That is, I think there's a
layer of abstraction missing; namely data types.

Database types are clearly much too coarse-grained for purposes other
than storage (other purposes like input, manipulation and display, for
example). Yet I may have more than one column in a database with the
same object type (or I may reuse somebody else's object type). The
proper place for display formatting of a type is certainly within the
type's view logic, but I'd argue that it is better placed in a Perl
module than in macros or whatever in a template. Indeed, CDBI already
has inflation logic if only I can get it to play nicely with Maypole and TT.

How do you write a single template function that can display any type of
object correctly? Or are you suggesting that there should be different
templates for every combination of field types? That sounds like a
maintenance nightmare.

I can certainly see an argument that the html_line_break filter should
be applied to *all* TEXT fields! I can't see why anybody would insert a
newline into a database value if they didn't want it to be preserved and
displayed. I'll try that as a solution to this specific problem.

Thanks, Dave

_______________________________________________
maypole mailing list
maypole at lists.netthink.co.uk
http://lists.netthink.co.uk/listinfo/maypole



This archive was generated by hypermail 2.1.3 : Thu Feb 24 2005 - 22:25:57 GMT