blib/lib/Yukki/Web/Plugin/Role/FormatHelper.pm untested

filter: Statementstmt 0.0% 0 / 13 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 3 Podpod n/a totaltotal 0.0% 0 / 16 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Yukki::Web::Plugin::Role::FormatHelper;
2 $Yukki::Web::Plugin::Role::FormatHelper::VERSION = '0.991_002'; # TRIAL
3  
4 $Yukki::Web::Plugin::Role::FormatHelper::VERSION = '0.991002';use v5.24;
5 use utf8;
6 use Moo::Role;
7  
8 # ABSTRACT: interface for quick format helpers
9  
10  
11 requires qw( format_helpers );
12  
13 1;
14  
15 __END__
16  
17 =pod
18  
19 =encoding UTF-8
20  
21 =head1 NAME
22  
23 Yukki::Web::Plugin::Role::FormatHelper - interface for quick format helpers
24  
25 =head1 VERSION
26  
27 version 0.991_002
28  
29 =head1 SYNOPSIS
30  
31 package MyPlugins::LowerCase;
32 use 5.12.1;
33 use Moo;
34  
35 use Types::Standard qw( HashRef Str );
36  
37 extends 'Yukki::Web::Plugin';
38  
39 has format_helpers => (
40 is => 'ro',
41 isa => HashRef[Str],
42 default => sub { +{
43 'lc' => 'lc_helper',
44 } },
45 );
46  
47 with 'Yukki::Web::Plugin::Role::FormatHelper';
48  
49 sub lc_helper {
50 my ($self, $params) = @_;
51 return lc $params->{arg};
52 }
53  
54 =head1 DESCRIPTION
55  
56 This role defines the interface for quick yukkitext helpers. Each plugin implementing this role may provide code references for embedding content in yukkitext using a special C<{{...}}> notation.
57  
58 =head1 REQUIRED METHODS
59  
60 An implementor must provide the following methods.
61  
62 =head2 format_helpers
63  
64 This must return a reference to hash mapping quick helper names to method names that may be called to handle them.
65  
66 The names may be any text that does not contain a colon (":").
67  
68 The methods will be called with the following parameters:
69  
70 =over
71  
72 =item context
73  
74 The curent L<Yukki::Web::Context> object.
75  
76 =item file
77  
78 This is the L<Yukki::Model::File> being formatted.
79  
80 =item helper_name
81  
82 The helper name the user used.
83  
84 =item arg
85  
86 The string argument passed to it.
87  
88 =back
89  
90 When called the method must return a scalar value to insert into the page. This is generally a string and may include any markup that should be added to the page.
91  
92 If the method throws and exception or returns C<undef> or something other than a scalar, the yukkitext formatter will include the original C<{{...}}> string as-is.
93  
94 =head1 AUTHOR
95  
96 Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
97  
98 =head1 COPYRIGHT AND LICENSE
99  
100 This software is copyright (c) 2017 by Qubling Software LLC.
101  
102 This is free software; you can redistribute it and/or modify it under
103 the same terms as the Perl 5 programming language system itself.
104  
105 =cut