Commit | Line | Data |
e2e866b4 |
1 | NAME |
8a28782a |
2 | Catalyst::View::ContentNegotiation::XHTML - Adjusts the response |
3 | Content-Type header to application/xhtml+xml if the browser accepts it. |
e2e866b4 |
4 | |
5 | SYNOPSIS |
6 | package Catalyst::View::TT; |
7 | |
8 | use Moose; |
9 | use namespace::clean -except => 'meta'; |
10 | |
11 | extends qw/Catalyst::View::TT/; |
12 | with qw/Catalyst::View::ContentNegotiation::XHTML/; |
13 | |
14 | 1; |
15 | |
16 | DESCRIPTION |
8a28782a |
17 | This is a simple Role which sets the response "Content-Type" to be |
e2e866b4 |
18 | "application/xhtml+xml" if the users browser sends an "Accept" header |
19 | indicating that it is willing to process that MIME type. |
20 | |
8a28782a |
21 | Changing the "Content-Type" to "application/xhtml+xml" causes browsers |
22 | to interpret the page as XML, meaning that your markup must be well |
23 | formed. |
e2e866b4 |
24 | |
8a28782a |
25 | CAVEATS |
e2e866b4 |
26 | This is useful when you're developing your application, as you know that |
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 | |
8a28782a |
30 | Whilst this module is has been tested against most popular browsers |
31 | including Internet Explorer, it may cause unexpected results on browsers |
32 | which do not properly support the "application/xhtml+xml" MIME type. |
33 | |
e2e866b4 |
34 | METHOD MODIFIERS |
35 | after process |
36 | Changes the response "Content-Type" if appropriate (from the requests |
37 | "Accept" header). |
38 | |
39 | METHODS |
40 | pragmatic_accept |
41 | Some browsers (such as Internet Explorer) have a nasty way of sending |
42 | Accept */* and this claiming to support XHTML just as well as HTML. |
43 | Saving to a file on disk or opening with another application does count |
44 | as accepting, but it really should have a lower q value then text/html. |
45 | This sub takes a pragmatic approach and corrects this mistake by |
46 | modifying the Accept header before passing it to content negotiation. |
47 | |
48 | ATTRIBUTES |
49 | variants |
50 | Returns an array ref of 3 part arrays, comprising name, priority, output |
51 | mime-type, which is used for the content negotiation algorithm. |
52 | |
53 | PRIVATE METHODS |
54 | _build_variants |
55 | Returns the default variant attribute contents. |
56 | |
57 | SEE ALSO |
58 | Catalyst::View::TT::XHTML - Trivial Catalyst TT view using this role. |
59 | <http://www.w3.org/Protocols/rfc2616/rfc2616-sec12.html> - Content |
60 | negotiation RFC. |
61 | |
62 | BUGS |
e2e866b4 |
63 | Should be split into a base ContentNegotiation role which is consumed by |
64 | ContentNegotiation::XHTML. |
65 | |
66 | AUTHOR |
8a28782a |
67 | Original author and maintainer - Tomas Doran (t0m) |
68 | "<bobtfish@bobtfish.net>" |
e2e866b4 |
69 | |
70 | CONTRIBUTORS |
8a28782a |
71 | David Dorward - test patches and */* pragmatism to make it work for |
72 | browsers which aren't firefox. |
e2e866b4 |
73 | Florian Ragwitz (rafl) "<rafl@debian.org>" - Conversion into a Moose |
8a28782a |
74 | Role, which is what the module should have been originally. |
e2e866b4 |
75 | |
76 | COPYRIGHT |
77 | This module itself is copyright (c) 2008 Tomas Doran and is licensed |
78 | under the same terms as Perl itself. |
79 | |