96
|
2 |
5 |
0 |
$c->stash->{$stash_key} ||= do {
if ($proto) {
foreach my $field (@fields) {
if (ref $proto eq 'HASH') {
$args{$field} = $proto->{$field} if exists $proto->{$field};
}
else {
if (my $cb = $proto->can($field)) {
$args{$field} = $proto->$field;
};
};
};
};
my $args = $self->merge_config_hashes($self->config, \%args);
$args = $self->modify_context_args($c, $args) if $self->can('modify_context_args');
$self->handle_request($c, %$args) if $self->can('handle_request');
my $template;
if (exists $args->{'template'}) {
$template = delete $args->{'template'};
}
elsif (exists $args->{'template_src'}) {
$template = delete $args->{'template_src'}->slurp;
};
my $directives = delete $args->{'directives'};
my $filters = delete $args->{'filters'};
my $pure_class = exists $args->{'pure_class'} ? delete $args->{'pure_class'} : 'Template::Pure';
Catalyst::Utils::ensure_class_loaded($pure_class);
my $view = ref($self)->new(%{$args;}, %{$c->stash;}, 'ctx', $c);
&weaken(my $weak_view = $view);
my $pure = $pure_class->new('template', $template, 'directives', $directives, 'filters', $filters, 'components', $self->build_comp_hash($c, $view), 'view', $weak_view, %$args);
$view->{'pure'} = $pure;
$view
}
|