-
-
22 Oct 2020 05:02:16 UTC
- Distribution: Mojolicious-Plugin-RenderCGI
- Module version: 0.102
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Repository
- Issues (1)
- Testers (141 / 0 / 0)
- Kwalitee
Bus factor: 1- 70.05% Coverage
- License: perl_5
- Perl: v5.6.0
- Activity
24 month- Tools
- Download (6.87KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
++ed by:1 non-PAUSE user- Dependencies
- CGI
- Mojolicious
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
- Mojolicious::Plugin::RenderCGI
- NAME
- SYNOPSIS
- Template
- NOTE about autoloading subs and methods
- OPTIONS
- Methods, subs, helpers...
- SEE ALSO
- AUTHOR
- BUGS / CONTRIBUTING
- COPYRIGHT
Доброго всем
Mojolicious::Plugin::RenderCGI
¡ ¡ ¡ ALL GLORY TO GLORIA ! ! !
NAME
Mojolicious::Plugin::RenderCGI - Rendering Mojoliciuos template by CGI.pm subs as tags.
SYNOPSIS
$app->plugin('RenderCGI');
Template
Template is a Perl code that generate content as list of statements. Similar to
do BLOCK
. Template file name like "templates/foo/bar.html.cgi.pl"# There are predefined variables: # $self is a Mojolicious::Plugin::RenderCGI::Template object # $c is a current controller object # $cgi is a CGI object $c->layout('default', handler=>'ep',);# set handler 'ep' for all templates/includes !!! even default handler cgi my $foo = $c->stash('foo') or die "Where is your FOO?"; #======================================= #======= content comma list! =========== #======================================= h1({}, "Welcome"),# but this template handlered CGI div({-class=>"container"}, span('Okay here'), p(['blah', 'blaz']), ), $c->include('foo', handler=>'cgi.pl'),# change handler against layout $c->include('bar'); # handler still "ep" unless template "foo" (and its includes) didn`t changes it by $c->stash('handler'=>...) <<END_HTML, <!-- comment --> END_HTML $self->app->log->info("Template has done") && undef,
There are NO Mojolicious helpers without OO-style prefixes:
$c->
.REMEMBER! Escapes untrusted data. No auto escapes!
div({}, esc(...UNTRUSTED DATA...)),
esc
is a shortcut for &CGI::escapeHTML.NOTE about autoloading subs and methods
In template you can generate any tag:
# <foo-tag class="class1">...</foo-tag> foo_tag({-class=>"class1",}, '...'), # same $self->foo_tag({-class=>"class1",}, '...'),
OPTIONS
handler_name ( string )
# Mojolicious::Lite plugin RenderCGI => {handler_name => 'pl'};
Handler name, defaults to cgi.pl.
default (bool)
When
true
then default handler. Defaults - 0 (no this default handler for app).default => 1,
Is similar to
$app->defaults(handler=> <name above>);
cgi_import ( string (space delims) | arrayref )
What subs do you want from CGI.pm import
$app->plugin('RenderCGI', cgi_import=>':html ...'); # or $app->plugin('RenderCGI', cgi_import=>[qw(:html ...)]);
See at perldoc CGI.pm section "USING THE FUNCTION-ORIENTED INTERFACE". Default is ':html :form' (string) same as [qw(:html :form)] (arrayref).
cgi_import=>[], # none import subs CGI
exception ( string | hashref )
To show fatal errors (not found, compile and runtime errors) as content of there template you must set string template.
Set string comment same above but include html comment tag
<!-- $error -->
To show fatals as standard Mojolicious 'exception.<mode>.html.ep' page - set hashref like {'handler'=>'ep', 'layout' => undef,}.
Overwise fatals are skips (empty string whole template).
By default set to hashref
{'handler'=>'ep', 'layout' => undef,}
.exception => 'template',
Methods, subs, helpers...
Implements register method only. Register new renderer handler. No new helpers.
SEE ALSO
Mojolicious::Plugin::TagHelpers
AUTHOR
Михаил Че (Mikhail Che),
<mche[-at-]cpan.org>
BUGS / CONTRIBUTING
Please report any bugs or feature requests at https://github.com/mche/Mojolicious-Plugin-RenderCGI/issues. Pull requests also welcome.
COPYRIGHT
Copyright 2016+ Mikhail Che.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install Mojolicious::Plugin::RenderCGI, copy and paste the appropriate command in to your terminal.
cpanm Mojolicious::Plugin::RenderCGI
perl -MCPAN -e shell install Mojolicious::Plugin::RenderCGI
For more information on module installation, please visit the detailed CPAN module installation guide.