| 1 | package Yukki::Web::Plugin; | ||
| 2 | $Yukki::Web::Plugin::VERSION = '0.991_002'; # TRIAL | ||
| 3 | |||
| 4 | $Yukki::Web::Plugin::VERSION = '0.991002';use v5.24; | ||
| 5 | use utf8; | ||
| 6 | use Moo; | ||
| 7 | |||
| 8 | use Type::Utils; | ||
| 9 | |||
| 10 | use namespace::clean; | ||
| 11 | |||
| 12 | # ABSTRACT: base class for Yukki plugins | ||
| 13 | |||
| 14 | |||
| 15 | has app => ( | ||
| 16 | is => 'ro', | ||
| 17 | isa => class_type('Yukki::Web'), | ||
| 18 | required => 1, | ||
| 19 | weak_ref => 1, | ||
| 20 | handles => 'Yukki::Role::App', | ||
| 21 | ); | ||
| 22 | |||
| 23 | 1; | ||
| 24 | |||
| 25 | __END__ | ||
| 26 | |||
| 27 | =pod | ||
| 28 | |||
| 29 | =encoding UTF-8 | ||
| 30 | |||
| 31 | =head1 NAME | ||
| 32 | |||
| 33 | Yukki::Web::Plugin - base class for Yukki plugins | ||
| 34 | |||
| 35 | =head1 VERSION | ||
| 36 | |||
| 37 | version 0.991_002 | ||
| 38 | |||
| 39 | =head1 SYNOPSIS | ||
| 40 | |||
| 41 | package MyPlugins::LowerCase; | ||
| 42 | use 5.12.1; | ||
| 43 | use Moo; | ||
| 44 | |||
| 45 | use Types::Standard qw( HashRef CodeRef ); | ||
| 46 | |||
| 47 | extends 'Yukki::Web::Plugin'; | ||
| 48 | |||
| 49 | has format_helpers => ( | ||
| 50 | is => 'ro', | ||
| 51 | isa => HashRef[CodeRef], | ||
| 52 | default => sub { +{ | ||
| 53 | 'lc' => \&lc_helper, | ||
| 54 | } }, | ||
| 55 | ); | ||
| 56 | |||
| 57 | with 'Yukki::Web::Plugin::Role::FormatHelper'; | ||
| 58 | |||
| 59 | sub lc_helper { | ||
| 60 | my ($params) = @_; | ||
| 61 | return lc $params->{arg}; | ||
| 62 | } | ||
| 63 | |||
| 64 | =head1 DESCRIPTION | ||
| 65 | |||
| 66 | 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: | ||
| 67 | |||
| 68 | =over | ||
| 69 | |||
| 70 | =item * | ||
| 71 | |||
| 72 | L<Yukki::Web::Plugin::Role::Formatter>. Formats a file for output as HTML. | ||
| 73 | |||
| 74 | =item * | ||
| 75 | |||
| 76 | L<Yukki::Web::Plugin::Role::FormatHelper>. This gives you the ability to create quick helpers in your yukkitext using the C<{{helper:...}}> notation. | ||
| 77 | |||
| 78 | =back | ||
| 79 | |||
| 80 | =head1 ATTRIBUTES | ||
| 81 | |||
| 82 | =head2 app | ||
| 83 | |||
| 84 | This is the L<Yukki::Web> singleton. All the methods required in L<Yukki::Role::App> will be delegated. | ||
| 85 | |||
| 86 | =head1 AUTHOR | ||
| 87 | |||
| 88 | Andrew Sterling Hanenkamp <hanenkamp@cpan.org> | ||
| 89 | |||
| 90 | =head1 COPYRIGHT AND LICENSE | ||
| 91 | |||
| 92 | This software is copyright (c) 2017 by Qubling Software LLC. | ||
| 93 | |||
| 94 | This is free software; you can redistribute it and/or modify it under | ||
| 95 | the same terms as the Perl 5 programming language system itself. | ||
| 96 | |||
| 97 | =cut |