| 1 | package Template::Mustache::Token::Section; | ||||||||||
| 2 | 22 | our $AUTHORITY = 'cpan:YANICK'; | |||||||||
| 3 | # ABSTRACT: Object representing a Section block | ||||||||||
| 4 | 22 | $Template::Mustache::Token::Section::VERSION = '1.3.3'; | |||||||||
| 5 | 22 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 22 | ▶ | use MooseX::MungeHas { has_ro => [ 'is_ro' ] }; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 22 | has_ro 'variable'; | |||||||||
| 10 | 22 | has_ro 'template'; | |||||||||
| 11 | 22 | has_ro 'inverse'; | |||||||||
| 12 | 22 | has_ro 'delimiters'; | |||||||||
| 13 | 22 | has_ro 'raw'; | |||||||||
| 14 | |||||||||||
| 15 | 22 | ▶ | use Template::Mustache; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | sub render { | ||||||||||
| 18 | 11 | ▶ | my( $self, $context, $partials, $indent ) = @_; | ||||||||
|
Subroutine
render: called CC=7 SCAR=22.0
Pod
undocumented
| |||||||||||
| 19 | |||||||||||
| 20 | 11 | my $cond = Template::Mustache::resolve_context( $self->variable, $context ); | |||||||||
| 21 | |||||||||||
| 22 | 11 | ▶ | if ( ref $cond eq 'CODE' ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | my $value=Template::Mustache->new( | ||||||||||
| 24 | delimiters => $self->delimiters, | ||||||||||
| 25 | template => $cond->( | ||||||||||
| 26 | $self->raw, | ||||||||||
| 27 | sub { | ||||||||||
| 28 | 2 | ▶ | Template::Mustache->new( template=> shift )->parsed->render( | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 29 | $context, $partials, $indent | ||||||||||
| 30 | ) } | ||||||||||
| 31 | ) | ||||||||||
| 32 | 2 | )->parsed->render( $context, $partials ); | |||||||||
| 33 | |||||||||||
| 34 | 2 | ▶ | return '' if $self->inverse; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 2 | return $value; | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 9 | ▶ | if ( $self->inverse ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 0 | ▶ | if ( ref $cond eq 'ARRAY' ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 0 | $cond = ! @$cond; | |||||||||
| 41 | }else { | ||||||||||
| 42 | 0 | $cond = !$cond; | |||||||||
| 43 | } | ||||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 9 | ▶ | return unless $cond; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | |||||||||||
| 48 | 9 | ▶ | return join '', map { $self->template->render( [ $_, @$context ], $partials ) } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | ref $cond eq 'ARRAY' ? @$cond : ( $cond ); | ||||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | 22 | 1; | |||||||||
| 53 | |||||||||||
| 54 | __END__ | ||||||||||
| 55 | |||||||||||
| 56 | =pod | ||||||||||
| 57 | |||||||||||
| 58 | =encoding UTF-8 | ||||||||||
| 59 | |||||||||||
| 60 | =head1 NAME | ||||||||||
| 61 | |||||||||||
| 62 | Template::Mustache::Token::Section - Object representing a Section block | ||||||||||
| 63 | |||||||||||
| 64 | =head1 VERSION | ||||||||||
| 65 | |||||||||||
| 66 | version 1.3.3 | ||||||||||
| 67 | |||||||||||
| 68 | =head1 AUTHORS | ||||||||||
| 69 | |||||||||||
| 70 | =over 4 | ||||||||||
| 71 | |||||||||||
| 72 | =item * | ||||||||||
| 73 | |||||||||||
| 74 | Pieter van de Bruggen <pvande@cpan.org> | ||||||||||
| 75 | |||||||||||
| 76 | =item * | ||||||||||
| 77 | |||||||||||
| 78 | Yanick Champoux <yanick@cpan.org> | ||||||||||
| 79 | |||||||||||
| 80 | =item * | ||||||||||
| 81 | |||||||||||
| 82 | Ricardo Signes <rjbs@cpan.org> | ||||||||||
| 83 | |||||||||||
| 84 | =back | ||||||||||
| 85 | |||||||||||
| 86 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 87 | |||||||||||
| 88 | This software is copyright (c) 2019, 2018, 2017, 2016, 2015, 2011 by Pieter van de Bruggen. | ||||||||||
| 89 | |||||||||||
| 90 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 91 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 92 | |||||||||||
| 93 | =cut | ||||||||||