Catalyst-View-ByCode
view release on metacpan or search on metacpan
lib/Catalyst/View/ByCode/Renderer.pm view on Meta::CPAN
# everything else is stringified
: "$_"
} @_);
}
######################################## EXPORTED FUNCTIONS
#
# a template definition instead of sub RUN {}
#
sub template(&) {
my $package = caller;
my $code = shift;
no strict 'refs';
*{"$package\::RUN"} = sub {
push @{$top[-1]}, [ '', {} ];
push @top, $top[-1]->[-1];
my $text = $code->();
lib/Catalyst/View/ByCode/Renderer.pm view on Meta::CPAN
pop @top;
return;
};
return;
}
#
# a block definition
#
sub block($&;@) {
my $name = shift;
my $code = shift;
my $package = caller;
no strict 'refs';
no warnings 'redefine';
#
# generate a sub in our namespace
lib/Catalyst/View/ByCode/Renderer.pm view on Meta::CPAN
# a special sub-rendering command like Rails ;-)
#
# yield \&name_of_a_sub;
# yield a_named_yield;
# yield 'content';
# yield; # same as 'content'
# yield 'path/to/template.pl'
# ### TODO: yield package::subname
# ### TODO: yield +package::package::package::subname
#
sub yield(;*@) {
my $yield_name = shift || 'content';
$c->log->debug("yield '$yield_name' executing...") if $c->debug;
_yield(exists($c->stash->{yield}->{$yield_name})
? $c->stash->{yield}->{$yield_name}
: $yield_name)
or $c->log->info("could not yield '$yield_name'");
return;
lib/Catalyst/View/ByCode/Renderer.pm view on Meta::CPAN
foreach my $d (@doctype_finder) {
if ($kind =~ m{\A $d->[0]}xmsi) {
$doctype = $d->[1];
last;
}
}
push @{$top[-1]}, $doctype_for{$doctype};
}
sub boilerplate(;&) {
my $code = shift;
push @{$top[-1]}, <<HTML;
<!--[if lt IE 7 ]> <html class="no-js ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]> <html class="no-js ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]> <html class="no-js ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
HTML
if ($code) {
( run in 1.216 second using v1.01-cache-2.11-cpan-65fba6d93b7 )