Created
May 20, 2014 23:40
-
-
Save memememomo/3023cb6e1938755e1fd8 to your computer and use it in GitHub Desktop.
Mojoliciousのプラグインを作る ref: http://qiita.com/uchiko/items/58f33ae7724b7fd720fb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Mojolicious::Plugin::Example; | |
use Mojo::Base 'Mojolicious::Plugin'; | |
sub register { | |
my ($self, $app, $conf) = @_; | |
} | |
1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mkdir -p lib/Mojolicious/Plugin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
push @{app->plugins->namespaces}, 'MyApp::Plugin'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Mojolicious::Plugin::Nl2br; | |
use Mojo::Base 'Mojolicious::Plugin'; | |
sub register { | |
my ($self, $app, $conf) = @_; | |
$app->helper('nl2br' => sub { | |
my ($c, $text) = @_; | |
$text =~ s/(\r\n|\n\r|\n|\r)/<br\/>$1/g; | |
return $text; | |
}); | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment