https://github.com/preaction/mojolicious-plugin-autoreload
Automatically reload open browser windows when your application changes
https://github.com/preaction/mojolicious-plugin-autoreload
Last synced: about 1 year ago
JSON representation
Automatically reload open browser windows when your application changes
- Host: GitHub
- URL: https://github.com/preaction/mojolicious-plugin-autoreload
- Owner: preaction
- License: other
- Created: 2018-03-18T20:19:02.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-08-05T03:21:24.000Z (almost 6 years ago)
- Last Synced: 2024-04-17T21:17:02.282Z (about 2 years ago)
- Language: Perl
- Homepage:
- Size: 56.6 KB
- Stars: 4
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.mkdn
- Changelog: CHANGES
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/preaction/Mojolicious-Plugin-AutoReload)
[](https://coveralls.io/r/preaction/Mojolicious-Plugin-AutoReload?branch=master)
# NAME
Mojolicious::Plugin::AutoReload - Automatically reload open browser windows when your application changes
# VERSION
version 0.010
# SYNOPSIS
use Mojolicious::Lite;
plugin AutoReload => {};
get '/' => 'index';
app->start;
__DATA__
@@ index.html.ep
Hello world!
# DESCRIPTION
This plugin automatically reloades the page when the Mojolicious webapp
restarts. This is especially useful when using [the Morbo development
server](http://mojolicious.org/perldoc/Mojolicious/Guides/Tutorial#Reloading),
which automatically restarts the webapp when it detects changes.
Combined, `morbo` and `Mojolicious::Plugin::AutoReload` will
automatically display your new content whenever you change your webapp
in your editor!
This works by opening a WebSocket connection to a specific Mojolicious
route. When the server restarts, the WebSocket is disconnected, which
triggers a reload of the page.
The AutoReload plugin will automatically add a `` tag to
your HTML pages while running in `development` mode. If you need to
control where this script tag is written, use the ["auto\_reload"](#auto_reload)
helper.
To disable the plugin for a single page, set the `plugin.auto_reload.disable` stash value to a true value:
get '/' => sub {
my ( $c ) = @_;
# Don't auto-reload the home page
$c->stash( 'plugin.auto_reload.disable' => 1 );
...
};
# HELPERS
## auto\_reload
The `auto_reload` template helper inserts the JavaScript to
automatically reload the page. This helper only works when the
application mode is `development`, so you can leave this in all the
time and have it only appear during local development.
This is only needed if you want to control where the `<script>`
for automatically-reloading is rendered.
# ROUTES
## /auto\_reload
This plugin adds a `/auto_reload` WebSocket route to your application.
# SEE ALSO
[Mojolicious](https://metacpan.org/pod/Mojolicious)
# THANKS
Thanks to [Grant Street Group](https://grantstreet.com) for funding
continued development of this plugin!
# AUTHOR
Doug Bell <preaction@cpan.org>
# CONTRIBUTORS
- Robert DeRose <RobertDeRose@users.noreply.github.com>
- Zeeshan Muhammad <zeeshan@dkhr.com>
# COPYRIGHT AND LICENSE
This software is copyright (c) 2018 by Doug Bell.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.