Merge to trunk, add version note
[catagits/Catalyst-View-ContentNegotiation-XHTML.git] / README
CommitLineData
06cf3efb 1NAME
778b6a5a 2 Catalyst::View::ContentNegotiation::XHTML - A Moose Role to apply to
3 Catalyst views adjusts the response Content-Type header to
4 application/xhtml+xml content if the browser accepts it.
06cf3efb 5
6SYNOPSIS
778b6a5a 7 package Catalyst::View::TT;
8
9 use Moose;
10 use namespace::clean -except => 'meta';
11
12 extends qw/Catalyst::View::TT/;
13 with qw/Catalyst::View::ContentNegotiation::XHTML/;
14
06cf3efb 15 1;
778b6a5a 16
06cf3efb 17DESCRIPTION
778b6a5a 18 This is a very simple Role which uses a method modifier to run after the
19 "process" method, and sets the response "Content-Type" to be
20 "application/xhtml+xml" if the users browser sends an "Accept" header
21 indicating that it is willing to process that MIME type.
0f9bcf09 22
06cf3efb 23 Changing the "Content-Type" causes browsers to interpret the page as
778b6a5a 24 XML, meaning that the markup must be well formed.
0f9bcf09 25
06cf3efb 26 This is useful when you're developing your application, as you know that
778b6a5a 27 all pages you view are parsed as XML, so any errors caused by your
28 markup not being well-formed will show up at once.
29
30METHOD MODIFIERS
31 after process
32 Changes the response "Content-Type" if appropriate (from the requests
33 "Accept" header).
0f9bcf09 34
06cf3efb 35METHODS
778b6a5a 36 pragmatic_accept
37 Some browsers (such as Internet Explorer) have a nasty way of sending
38 Accept */* and this claiming to support XHTML just as well as HTML.
39 Saving to a file on disk or opening with another application does count
40 as accepting, but it really should have a lower q value then text/html.
41 This sub takes a pragmatic approach and corrects this mistake by
42 modifying the Accept header before passing it to content negotiation.
0f9bcf09 43
778b6a5a 44ATTRIBUTES
45 variants
46 Returns an array ref of 3 part arrays, comprising name, priority, output
47 mime-type, which is used for the content negotiation algorithm.
48
49PRIVATE METHODS
50 _build_variants
51 Returns the default variant attribute contents.
0f9bcf09 52
778b6a5a 53SEE ALSO
54 Catalyst::View::TT::XHTML - Trivial Catalyst TT view using this role.
55 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec12.html> - Content
56 negotiation RFC.
57
58BUGS
59 Will only work with Views which implement a process method.
0f9bcf09 60
778b6a5a 61 Should be split into a base ContentNegotiation role which is consumed by
62 ContentNegotiation::XHTML.
0f9bcf09 63
06cf3efb 64AUTHOR
778b6a5a 65 Tomas Doran (t0m) "<bobtfish@bobtfish.net>"
06cf3efb 66
67CONTRIBUTORS
778b6a5a 68 David Dorward - test patches and */* pragmatism.
69 Florian Ragwitz (rafl) "<rafl@debian.org>" - Conversion into a Moose
70 Role
0f9bcf09 71
06cf3efb 72COPYRIGHT
73 This module itself is copyright (c) 2008 Tomas Doran and is licensed
74 under the same terms as Perl itself.
0f9bcf09 75