1 package Catalyst::View::TT::XHTML;
4 use HTTP::Negotiate qw(choose);
6 use base qw/Catalyst::View::TT/;
8 our $VERSION = '1.002';
11 [qw| xhtml 1.000 application/xhtml+xml |],
12 [qw| html 0.001 text/html |],
18 my $return = $self->next::method(@_);
20 if ($c->request->header('Accept') && $c->response->headers->{'content-type'} =~ m|text/html|) {
21 my $var = choose($variants, $c->request->headers);
22 if ($var eq 'xhtml') {
23 $c->response->headers->{'content-type'} =~ s|text/html|application/xhtml+xml|;
35 Catalyst::View::TT::XHTML - A sub-class of the standard TT view which
36 serves application/xhtml+xml content if the browser accepts it.
40 package MyApp::View::XHTML;
43 use base qw/Catalyst::View::TT::XHTML MyApp::View::TT/;
49 This is a very simple sub-class of L<Catalyst::View::TT>, which sets
50 the response C<Content-Type> to be C<application/xhtml+xml> if the
51 user's browser sends an C<Accept> header indicating that it is willing
52 to process that MIME type.
54 Changing the C<Content-Type> causes browsers to interpret the page as
55 strict XHTML, meaning that the markup must be well formed.
57 This is useful when you're developing your application, as you know that
58 all pages you view are rendered strictly, so any markup errors will show
65 Overrides the standard process method, delegating to L<Catalyst::View::TT>
66 to render the template, and then changing the response C<Content-Type> if
67 appropriate (from the requests C<Accept> header).
71 There should be a more elegant way to inherit the config of your normal
74 Configuration (as loaded by L<Catalyst::Plugin::ConfigLoader>) for the TT
77 No helper to generate the view file needed (just copy the code in the
82 Tomas Doran C<< <bobtfish@bobtfish.net> >>
88 =item David Dorward - test patches
94 This module itself is copyright (c) 2008 Tomas Doran and is licensed under the same terms as Perl itself.