Browse Source

+ LDV::Helpers

master
Alex 'AdUser' Z 9 years ago
parent
commit
e63a60c836
  1. 3
      lib/LDV.pm
  2. 27
      lib/LDV/Helpers.pm

3
lib/LDV.pm

@ -9,9 +9,10 @@ use Mojo::Base 'Mojolicious';
sub startup { sub startup {
my ($self) = @_; my ($self) = @_;
$self->plugin(I18N => {default => 'ru'});
my $config = $self->app->home->rel_file('conf/ldv.conf'); my $config = $self->app->home->rel_file('conf/ldv.conf');
$self->plugin(Config => {file => $config}); $self->plugin(Config => {file => $config});
$self->plugin(I18N => {default => 'ru'});
$self->plugin('LDV::Helpers');
$self->app->mode('production'); $self->app->mode('production');
$self->app->secrets([ $self->app->config->{secret} ]); $self->app->secrets([ $self->app->config->{secret} ]);

27
lib/LDV/Helpers.pm

@ -0,0 +1,27 @@
package LDV::Helpers;
use strict;
use warnings;
use utf8;
use Mojo::Base 'Mojolicious::Plugin';
use Text::Markdown;
sub register {
my ($self, $app) = @_;
$app->helper(markdown => sub {
my ($c, $text) = @_;
my $render = Text::Markdown->new;
return $render->markdown($text);
});
$app->helper(plaintext => sub {
my ($c, $text) = @_;
$text =~ s{\r?\n}{<br/>}go;
return $text;
});
}
1;
Loading…
Cancel
Save