Yukki::Web::Plugin::Role::Formatter - interface for HTML formatters
version 0.140290
package MyPlugins::SimpleText; use 5.12.1; use Moose; extends 'Yukki::Web::Plugin'; has html_formatters => ( is => 'ro', isa => 'HashRef[Str]', default => sub { +{ 'text/simple' => 'format_simple', } }, ); with 'Yukki::Web::Plugin::Role::Formatter; sub format_simple { my ($self, $file) = @_; my $html = $file->fetch; $html =~ s/$/<br>/g; return [ { title => 'Simple' }, $html ]; }
This role defines the interface for file formatters. The first formatter matching the MIME type for a file will be used to format a page's contents as HTML.
This must return a reference to a hash mapping MIME-types to method names.
The methods will be called with a hashref parameter containing the following:
The current Yukki::Web::Context object.
The name of the repository this file is in.
The full path to the name of the file being formatted.
This is the media type that Yukki has detected for the file.
The body of the page as a string.
The method should return an HTML document.
my $yes_or_no = $formatter->has_format($media_type);
Returns true if this formatter plugin has a formatter for the named media type.
my $html = $self->format({ context => $ctx, repository => $repository, page => $full_path, media_type => $media_type, content => $content, });
Renders the text as HTML. If this plugin cannot format this media type, it returns undef.
undef
Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
This software is copyright (c) 2014 by Qubling Software LLC.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Yukki, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Yukki
CPAN shell
perl -MCPAN -e shell install Yukki
For more information on module installation, please visit the detailed CPAN module installation guide.