File Coverage

blib/lib/Template/Plugin/Filter/PlantUML.pm
Criterion Covered Total %
statement 25 25 100.0
branch n/a
condition 1 2 50.0
subroutine 8 8 100.0
pod 2 2 100.0
total 36 37 97.3


line stmt bran cond sub pod time code
1             package Template::Plugin::Filter::PlantUML;
2              
3 2     2   121031 use 5.006;
  2         7  
4 2     2   13 use strict;
  2         4  
  2         42  
5 2     2   10 use warnings;
  2         4  
  2         91  
6              
7             require Template::Plugin::Filter;
8 2     2   11 use base qw(Template::Plugin::Filter);
  2         4  
  2         1016  
9 2     2   8181 use vars qw($VERSION $DYNAMIC $FILTER_NAME);
  2         6  
  2         109  
10              
11 2     2   890 use WWW::PlantUML;
  2         164899  
  2         399  
12              
13             =head1 NAME
14              
15             Template::Plugin::Filter::PlantUML - A template toolkit plugin filter for encoding and processing PlantUML Diagrams using a PlantUML Server.
16              
17             =head1 VERSION
18              
19             Version 0.01
20              
21             =cut
22              
23             our $VERSION = 0.01;
24             our $DYNAMIC = 1;
25             our $FILTER_NAME = 'plantuml';
26              
27             =head1 SYNOPSIS
28              
29             To use this plugin, you have to make sure that the Template Toolkit knows about its namespace.
30              
31             my $tt2 = Template->new({
32             PLUGIN_BASE => 'Template::Plugin::Filter::PlantUML',
33             });
34              
35             Then you C your plugin like below.
36              
37             [% USE Filter.PlantUML 'http://www.plantuml.com/plantuml' 'svg' -%]
38            
39             [% url = FILTER plantuml %]
40             Bob -> Alice : hello
41             [% END %]
42            
43             [% url %]
44              
45             =head1 DESCRIPTION
46              
47             This is a trivial Template::Toolkit plugin filter to allow any template writer to embed PlantUML Diagram Syntax in Templates and have them encoded and processed via any PlantUML Server in any supported formats.
48              
49             It uses C remote client under the hood.
50              
51             =head1 SUBROUTINES/METHODS
52              
53             =head2 init
54              
55             defines init() method.
56              
57             =cut
58              
59             sub init {
60 1     1 1 83 my $self = shift;
61 1         9 $self->install_filter($FILTER_NAME);
62 1         65 return $self;
63             }
64              
65             =head2 filter
66              
67             defines filter() method.
68              
69             =cut
70              
71             sub filter {
72 1     1 1 125 my ( $self, $code, $args, $conf ) = @_;
73              
74 1         8 $args = $self->merge_args($args);
75 1         17 $conf = $self->merge_config($conf);
76              
77 1         14 my $puml = WWW::PlantUML->new( @$args[0] );
78 1   50     23 return $puml->fetch_url( $code, @$args[1] || 'png' );
79             }
80              
81             =head1 AUTHOR
82              
83             Rangana Sudesha Withanage, C<< >>
84              
85             =head1 BUGS
86              
87             Please report any bugs or feature requests to C, or through
88             the web interface at L. I will be notified, and then you'll
89             automatically be notified of progress on your bug as I make changes.
90              
91              
92             =head1 SUPPORT
93              
94             You can find documentation for this module with the perldoc command.
95              
96             perldoc Template::Plugin::Filter::PlantUML
97              
98              
99             You can also look for information at:
100              
101             =over 4
102              
103             =item * RT: CPAN's request tracker (report bugs here)
104              
105             L
106              
107             =item * AnnoCPAN: Annotated CPAN documentation
108              
109             L
110              
111             =item * CPAN Ratings
112              
113             L
114              
115             =item * Search CPAN
116              
117             L
118              
119             =back
120              
121              
122             =head1 ACKNOWLEDGEMENTS
123              
124              
125             =head1 LICENSE AND COPYRIGHT
126              
127             This software is copyright (c) 2019 by Rangana Sudesha Withanage.
128              
129             This is free software; you can redistribute it and/or modify it under
130             the same terms as the Perl 5 programming language system itself.
131              
132              
133             =cut
134              
135             1; # End of Template::Plugin::Filter::PlantUML