NAME

Yukki::Web::Plugin::Role::FormatHelper - interface for quick format helpers

VERSION

version 0.991_004

SYNOPSIS

package MyPlugins::LowerCase;
use 5.12.1;
use Moo;

use Types::Standard qw( HashRef Str );

extends 'Yukki::Web::Plugin';

has format_helpers => (
    is          => 'ro',
    isa         => HashRef[Str],
    default     => sub { +{
        'lc' => 'lc_helper',
    } },
);

with 'Yukki::Web::Plugin::Role::FormatHelper';

sub lc_helper {
    my ($self, $params) = @_;
    return lc $params->{arg};
}

DESCRIPTION

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 {{...}} notation.

REQUIRED METHODS

An implementor must provide the following methods.

format_helpers

This must return a reference to hash mapping quick helper names to method names that may be called to handle them.

The names may be any text that does not contain a colon (":").

The methods will be called with the following parameters:

context

The curent Yukki::Web::Context object.

file

This is the Yukki::Model::File being formatted.

helper_name

The helper name the user used.

arg

The string argument passed to it.

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.

If the method throws and exception or returns undef or something other than a scalar, the yukkitext formatter will include the original {{...}} string as-is.

AUTHOR

Andrew Sterling Hanenkamp <hanenkamp@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 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.