NAME

Plack::App::Tags::HTML - Plack application for running Tags::HTML objects.

SYNOPSIS

 use Plack::App::Tags::HTML;

 my $obj = Plack::App::Tags::HTML->new(%parameters);
 my $app = $obj->to_app;

METHODS

Class inherites Plack::Component::Tags::HTML.

new

 my $obj = Plack::App::Tags::HTML->new(%parameters);

Constructor.

Returns instance of object.

  • component

    Tags::HTML component.

    Option is required.

  • constructor_args

    Tags::HTML component constructor arguments.

    Default value is undef.

  • data

    Array data structure as input argument of Tags::HTML::process().

    Default value is undef.

to_app

 my $app = $obj->to_app;

Get code of plack application.

Returns code of app.

ERRORS

 prepare_app():
         Cannot load component '%s'.
                 Error: %s
         Component must be a instance of 'Tags::HTML' class.

EXAMPLE1

 use strict;
 use warnings;

 use Plack::App::Tags::HTML;
 use Plack::Runner;

 # Run application.
 my $app = Plack::App::Tags::HTML->new(
         'component' => 'Tags::HTML::Stars',
         'data' => [{
                 1 => 'full',
                 2 => 'half',
                 3 => 'nothing',
         }],
 )->to_app;
 Plack::Runner->new->run($app);

 # Output:
 # HTTP::Server::PSGI: Accepting connections at http://0:5000/

 # > curl http://localhost:5000/
 # <!DOCTYPE html>
 # <html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /></head><body><div><img src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzAwcHgiIGhlaWdodD0iMjc1cHgiIHZpZXdCb3g9IjAgMCAzMDAgMjc1IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSI+CiAgPHBvbHlnb24gZmlsbD0iI2ZkZmYwMCIgc3Ryb2tlPSIjNjA1YTAwIiBzdHJva2Utd2lkdGg9IjE1IiBwb2ludHM9IjE1MCwyNSAxNzksMTExIDI2OSwxMTEgMTk3LDE2NSAyMjMsMjUxIDE1MCwyMDAgNzcsMjUxIDEwMywxNjUgMzEsMTExIDEyMSwxMTEiIC8+Cjwvc3ZnPgo="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PHBvbHlnb24gZmlsbD0ibm9uZSIgc3Ryb2tlPSIjODA4MDgwIiBzdHJva2Utd2lkdGg9IjE1IiBzdHJva2Utb3BhY2l0eT0iMC4zNzY0NzA2MCIgcG9pbnRzPSIxNTAsMjUgMTc5LDExMSAyNjksMTExIDE5NywxNjUgMjIzLDI1MSAxNTAsMjAwIDc3LDI1MSAxMDMsMTY1IDMxLDExMSAxMjEsMTExIiAvPgo8L3N2Zz4K" /></div></body></html>
Example #1 web application

EXAMPLE2

 use strict;
 use warnings;

 package App;

 use base qw(Tags::HTML);

 sub _process {
         my ($self, $value_hr) = @_;

         $self->{'tags'}->put(
                 ['b', 'div'],
                 ['a', 'class', 'my-class'],
                 ['d', join ',', @{$value_hr->{'foo'}}],
                 ['e', 'div'],
         );

         return;
 }

 sub _process_css {
         my $self = shift;

         $self->{'css'}->put(
                 ['s', '.my-class'],
                 ['d', 'border', '1px solid black'],
                 ['e'],
         );

         return;
 }

 package main;

 use Plack::App::Tags::HTML;
 use Plack::Runner;

 # Run application.
 my $app = Plack::App::Tags::HTML->new(
         'component' => 'App',
         'data' => [{
                 'foo' => [1, 2],
         }],
 )->to_app;
 Plack::Runner->new->run($app);

 # Output:
 # HTTP::Server::PSGI: Accepting connections at http://0:5000/

 # > curl http://localhost:5000/
 # <!DOCTYPE html>
 # <html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><style type="text/css">.my-class{border:1px solid black;}
 # </style></head><body><div class="my-class">1,2</div></body></html>

DEPENDENCIES

English, Error::Pure, Plack::Component::Tags::HTML, Plack::Util::Accessor, Symbol::Get.

SEE ALSO

Tags::HTML

Tags helper abstract class.

REPOSITORY

https://github.com/michal-josef-spacek/Plack-App-Tags-HTML

AUTHOR

Michal Josef Špaček mailto:skim@cpan.org

http://skim.cz

LICENSE AND COPYRIGHT

© 2021-2022 Michal Josef Špaček

BSD 2-Clause License

VERSION

0.07