Back to Home

Mojolicious :: Lite

perl · framework · mojolicious

Mojolicious :: Lite

    Sebastian Riedel never ceases to amaze; last Saturday he announced Mojolicious :: Lite . This is really cool, I haven’t seen this in the pearl yet, it’s really “quick start”:

    put the module:
    cpan Mojolicious :: Lite

    create a script:
    ! / usr / bin / perl
    use strict;
    use warnings;
    use Mojolicious :: Lite;
    get '/' => sub {
        my $ self = shift;
        $ self-> render (text => 'It works!');
    };
    shagadelic;
    run:
    perl ./mojolitetest.pl daemon
    that’s all, open http: // localhost: 3000 / in the browser and enjoy)

    but that’s not all I wanted to show, of course you can use the templates directly in the same script:
    ! / usr / bin / perl
    use strict;
    use warnings;
    use Mojolicious :: Lite;
    get '/' => sub {
        my $ self = shift;
        $ self-> render (text => 'It works!');
    };
    get '/ foo' => sub {
        my $ self = shift;
        $ self-> render (template => 'foo');
    };
    shagadelic;
    __DATA__
    @@ foo.html.eplite
    It's from template!
    we run the script and at http: // localhost: 3000 / foo we see:
    “It's from template!”

    more information on the module page

    Read Next