Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/michal-josef-spacek/plack-app-tags-html
Plack application for running Tags::HTML objects.
https://github.com/michal-josef-spacek/plack-app-tags-html
plack-app
Last synced: 17 days ago
JSON representation
Plack application for running Tags::HTML objects.
- Host: GitHub
- URL: https://github.com/michal-josef-spacek/plack-app-tags-html
- Owner: michal-josef-spacek
- License: bsd-2-clause
- Created: 2022-05-09T21:21:40.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-28T13:34:31.000Z (3 months ago)
- Last Synced: 2024-10-28T17:01:58.745Z (3 months ago)
- Topics: plack-app
- Language: Perl
- Homepage:
- Size: 271 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- Changelog: Changes
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
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.
* "data_css"
Reference to array with structure for input argument of
Tags::HTML::process_css().Default value is undef.
* "data_init"
Reference to array with structure for input argument of
Tags::HTML::init().This structure is used in init phase of each web app call.
Default value is undef.
* "data_prepare"
Reference to array with structure for input argument of
Tags::HTML::prepare().This structure is used in prepare phase of web app run.
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 CSS::Struct::Output::Indent;
use Plack::App::Tags::HTML;
use Plack::Runner;
use Tags::Output::Indent;# Run application.
my $app = Plack::App::Tags::HTML->new(
'component' => 'Tags::HTML::Stars',
'css' => CSS::Struct::Output::Indent->new,,
'data' => [{
1 => 'full',
2 => 'half',
3 => 'nothing',
}],
'tags' => Tags::Output::Indent->new(
'preserved' => ['style'],
),
)->to_app;
Plack::Runner->new->run($app);# Output:
# HTTP::Server::PSGI: Accepting connections at http://0:5000/# > curl http://localhost:5000/
#
#
#
#
#
#
#
#
# * {
# box-sizing: border-box;
# margin: 0;
# padding: 0;
# }
#
#
#
#
#
#
#
#
#
#
#
#
#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 CSS::Struct::Output::Indent;
use Plack::App::Tags::HTML;
use Plack::Runner;
use Tags::Output::Indent;# Run application.
my $app = Plack::App::Tags::HTML->new(
'component' => 'App',
'css' => CSS::Struct::Output::Indent->new,
'data' => [{
'foo' => [1, 2],
}],
'tags' => Tags::Output::Indent->new(
'preserved' => ['style'],
),
)->to_app;
Plack::Runner->new->run($app);# Output:
# HTTP::Server::PSGI: Accepting connections at http://0:5000/# > curl http://localhost:5000/
#
#
#
#
#
#
#
#
# * {
# box-sizing: border-box;
# margin: 0;
# padding: 0;
# }
# .my-class {
# border: 1px solid black;
# }
#
#
#
#
# 1,2
#
#
#DEPENDENCIES
English, Error::Pure, Plack::Component::Tags::HTML,
Plack::Util::Accessor, Symbol::Get.SEE ALSO
Tags::HTML
Tags helper abstract class.REPOSITORY
AUTHOR
Michal Josef Špaček
LICENSE AND COPYRIGHT
© 2021-2024 Michal Josef ŠpačekBSD 2-Clause License
VERSION
0.18