| 1 | package Mojolicious::Plugin::Text::Caml; | ||||||||||||||
| 2 | 1 | ▶ | use Mojo::Base 'Mojolicious::Plugin'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | |||||||||||||||
| 4 | 1 | ▶ | use Text::Caml; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | |||||||||||||||
| 6 | 1 | our $VERSION = '0.03'; | |||||||||||||
| 7 | |||||||||||||||
| 8 | sub register { | ||||||||||||||
| 9 | 1 | ▶ | my ($self, $app, $args) = @_; | ||||||||||||
|
Subroutine
register: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||
| 10 | |||||||||||||||
| 11 | 1 | ▶ | $args //= {}; | ||||||||||||
|
Condition50%1/2
$args //= {}
MC/DC0%0/1
$args //= {}
$args
Truth table50%1/2
A
A= $args
| |||||||||||||||
| 12 | 1 | my $caml = Text::Caml->new(%$args); | |||||||||||||
| 13 | |||||||||||||||
| 14 | $app->renderer->add_handler(caml => sub { | ||||||||||||||
| 15 | 2 | ▶ | my ($renderer, $c, $output, $options) = @_; | ||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=17.3
| |||||||||||||||
| 16 | |||||||||||||||
| 17 | 2 | ▶ | if ($options->{inline}) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 18 | 1 | my $inline_template = $options->{inline}; | |||||||||||||
| 19 | 1 | $$output = $caml->render($inline_template, $c->stash); | |||||||||||||
| 20 | } | ||||||||||||||
| 21 | elsif (my $template_name = $renderer->template_path($options)) { | ||||||||||||||
| 22 | 0 | $caml->set_templates_path($renderer->paths->[0]); | |||||||||||||
| 23 | 0 | $$output = $caml->render_file($template_name, $c->stash); | |||||||||||||
| 24 | } else { | ||||||||||||||
| 25 | 1 | my $data_template = $renderer->get_data_template($options); | |||||||||||||
| 26 | 1 | ▶ | $$output = $caml->render($data_template, $c->stash) if $data_template; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 27 | } | ||||||||||||||
| 28 | 2 | ▶ | return $$output ? 1 : 0; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 29 | 1 | }); | |||||||||||||
| 30 | |||||||||||||||
| 31 | 1 | return 1; | |||||||||||||
| 32 | } | ||||||||||||||
| 33 | |||||||||||||||
| 34 | 1 | 1; | |||||||||||||
| 35 | __END__ | ||||||||||||||