Commit | Line | Data |
e2e866b4 |
1 | NAME |
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. |
5 | |
6 | SYNOPSIS |
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 | |
15 | 1; |
16 | |
17 | DESCRIPTION |
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. |
22 | |
23 | Changing the "Content-Type" causes browsers to interpret the page as |
24 | XML, meaning that the markup must be well formed. |
25 | |
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 | |
30 | METHOD MODIFIERS |
31 | after process |
32 | Changes the response "Content-Type" if appropriate (from the requests |
33 | "Accept" header). |
34 | |
35 | METHODS |
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. |
43 | |
44 | ATTRIBUTES |
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 | |
49 | PRIVATE METHODS |
50 | _build_variants |
51 | Returns the default variant attribute contents. |
52 | |
53 | SEE 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 | |
58 | BUGS |
59 | Will only work with Views which implement a process method. |
60 | |
61 | Should be split into a base ContentNegotiation role which is consumed by |
62 | ContentNegotiation::XHTML. |
63 | |
64 | AUTHOR |
65 | Tomas Doran (t0m) "<bobtfish@bobtfish.net>" |
66 | |
67 | CONTRIBUTORS |
68 | David Dorward - test patches and */* pragmatism. |
69 | Florian Ragwitz (rafl) "<rafl@debian.org>" - Conversion into a Moose |
70 | Role |
71 | |
72 | COPYRIGHT |
73 | This module itself is copyright (c) 2008 Tomas Doran and is licensed |
74 | under the same terms as Perl itself. |
75 | |