[Catalyst] Validation of entered content

Octavian Rasnita orasnita at gmail.com
Mon Apr 11 16:05:44 GMT 2011


From: "John M. Dlugosz" <wxju46gefd at snkmail.com>
>I have a form where an admin can change a part of the content on a page.  The form lets 
> someone do it without having to update the files on the server in a more traditional 
> manner; BUT, it must be correct XHTML.  If the admin types a <p> or a stray '<' for that 
> matter, it will render the resulting page not well-formed.
> 
> Combine that with the feature of serving XHTML to browsers that accept it, and the site 
> breaks on browsers other than IE.
> 
> What's a good way to validate something programmatically before committing it?  Better 
> yet, is there a rich editor or wiki- or phpbbs-like translator that I might use for 
> soliciting the input that I might use instead?
> 
> The current content has a couple paragraphs and a bulleted list.  So it's not just a 
> simple blank, but must allow an amount of rich content.



Better than storing html, store a Textile format which is easy readable and similar to plain text when not rendered, but which renders as valid html.

You can use

http://search.cpan.org/~bchoate/Text-Textile-2.12/lib/Text/Textile.pm

or you can use 

http://search.cpan.org/~idoperel/DBIx-Class-InflateColumn-Markup-Unified-v0.21.1/lib/DBIx/Class/InflateColumn/Markup/Unified.pm

for beeing able to choose if you want to store the markup as Textile, Markdown or BBCode.

The Textile format allows the biggest flexibility and you can also use html elements in it, but you can create with its features headings, lists of different formats, tables with many settings, links, images, and many other things.

Octavian




More information about the Catalyst mailing list