The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

MojoX::Fixup::XHTML - serves application/xhtml+xml content for Mojo

SYNOPSIS

    package MyApp;
    
    use base 'Mojolicious';
    use MojoX::Fixup::XHTML;

    sub dispatch {
        my ($self, $c) = @_;

        # Try to find a static file
        my $done = $self->static->dispatch($c);

        # Use routes if we don't have a response code yet
        unless ( $done ) {
            $done = $self->routes->dispatch($c);
            if ( $done ) {
                MojoX::Fixup::XHTML->fix_xhtml( $c );
            }
        }

        # Nothing found, serve static file "public/404.html"
        unless ($done) {
            $self->static->serve($c, '/404.html');
            $c->res->code(404);
        }
    }

DESCRIPTION

This sets the response Content-Type to be application/xhtml+xml if the user's 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 strict XHTML, 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 rendered strictly, so any markup errors will show up at once.

ACKNOWLEDGEMENTS

Tomas Doran - Catalyst::View::TT::XHTML, most of the code are copied from there

COPYRIGHT & LICENSE

Copyright 2008 Fayland Lam, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.