File: | lib/Yukki/Web/Plugin.pm |
Coverage: | 100.0% |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | package Yukki::Web::Plugin; | ||||||
2 | |||||||
3 | 2 2 | 2869 11 | use v5.24; | ||||
4 | 2 2 2 | 11 5 12 | use utf8; | ||||
5 | 2 2 2 | 41 5 11 | use Moo; | ||||
6 | |||||||
7 | 2 2 2 | 682 5 17 | use Type::Utils; | ||||
8 | |||||||
9 | 2 2 2 | 3264 7 16 | use namespace::clean; | ||||
10 | |||||||
11 | # ABSTRACT: base class for Yukki plugins | ||||||
12 | |||||||
13 - 60 | =head1 SYNOPSIS package MyPlugins::LowerCase; use 5.12.1; use Moo; use Types::Standard qw( HashRef CodeRef ); extends 'Yukki::Web::Plugin'; has format_helpers => ( is => 'ro', isa => HashRef[CodeRef], default => sub { +{ 'lc' => \&lc_helper, } }, ); with 'Yukki::Web::Plugin::Role::FormatHelper'; sub lc_helper { my ($params) = @_; return lc $params->{arg}; } =head1 DESCRIPTION This is the base class for Yukki plugins. It doesn't do much but allow your plugin access to the application singleton and its configuration. For your plugin to actually do something, you must implement a plugin role. See these roles for details: =over =item * L<Yukki::Web::Plugin::Role::Formatter>. Formats a file for output as HTML. =item * L<Yukki::Web::Plugin::Role::FormatHelper>. This gives you the ability to create quick helpers in your yukkitext using the C<{{helper:...}}> notation. =back =head1 ATTRIBUTES =head2 app This is the L<Yukki::Web> singleton. All the methods required in L<Yukki::Role::App> will be delegated. =cut | ||||||
61 | |||||||
62 | has app => ( | ||||||
63 | is => 'ro', | ||||||
64 | isa => class_type('Yukki::Web'), | ||||||
65 | required => 1, | ||||||
66 | weak_ref => 1, | ||||||
67 | handles => 'Yukki::Role::App', | ||||||
68 | ); | ||||||
69 | |||||||
70 | 1; |