NAME Catalyst::View::ContentNegotiation::XHTML - A Moose Role to apply to Catalyst views adjusts the response Content-Type header to application/xhtml+xml content if the browser accepts it. SYNOPSIS package Catalyst::View::TT; use Moose; use namespace::clean -except => 'meta'; extends qw/Catalyst::View::TT/; with qw/Catalyst::View::ContentNegotiation::XHTML/; 1; DESCRIPTION This is a very simple Role which uses a method modifier to run after the "process" method, and sets the response "Content-Type" to be "application/xhtml+xml" if the users browser sends an "Accept" header indicating that it is willing to process that MIME type. Changing the "Content-Type" causes browsers to interpret the page as XML, meaning that the markup must be well formed. This is useful when you're developing your application, as you know that all pages you view are parsed as XML, so any errors caused by your markup not being well-formed will show up at once. METHOD MODIFIERS after process Changes the response "Content-Type" if appropriate (from the requests "Accept" header). METHODS pragmatic_accept Some browsers (such as Internet Explorer) have a nasty way of sending Accept */* and this claiming to support XHTML just as well as HTML. Saving to a file on disk or opening with another application does count as accepting, but it really should have a lower q value then text/html. This sub takes a pragmatic approach and corrects this mistake by modifying the Accept header before passing it to content negotiation. ATTRIBUTES variants Returns an array ref of 3 part arrays, comprising name, priority, output mime-type, which is used for the content negotiation algorithm. PRIVATE METHODS _build_variants Returns the default variant attribute contents. SEE ALSO Catalyst::View::TT::XHTML - Trivial Catalyst TT view using this role. - Content negotiation RFC. BUGS Will only work with Views which implement a process method. Should be split into a base ContentNegotiation role which is consumed by ContentNegotiation::XHTML. AUTHOR Tomas Doran (t0m) "" CONTRIBUTORS David Dorward - test patches and */* pragmatism. Florian Ragwitz (rafl) "" - Conversion into a Moose Role COPYRIGHT This module itself is copyright (c) 2008 Tomas Doran and is licensed under the same terms as Perl itself.