| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package DTL::Fast::Tag::Cycle; | 
| 2 | 2 |  |  | 2 |  | 1065 | use strict; use utf8; use warnings FATAL => 'all'; | 
|  | 2 |  |  | 2 |  | 6 |  | 
|  | 2 |  |  | 2 |  | 54 |  | 
|  | 2 |  |  |  |  | 10 |  | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 11 |  | 
|  | 2 |  |  |  |  | 50 |  | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 88 |  | 
| 3 | 2 |  |  | 2 |  | 9 | use parent 'DTL::Fast::Tag::Simple'; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 11 |  | 
| 4 |  |  |  |  |  |  |  | 
| 5 |  |  |  |  |  |  | $DTL::Fast::TAG_HANDLERS{'cycle'} = __PACKAGE__; | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | #@Override | 
| 8 |  |  |  |  |  |  | sub parse_parameters | 
| 9 |  |  |  |  |  |  | { | 
| 10 | 11 |  |  | 11 | 0 | 8 | my $self = shift; | 
| 11 |  |  |  |  |  |  |  | 
| 12 | 11 |  |  |  |  | 133 | $self->{'parameter'} =~ /^\s*(.+?)\s*(?:as (.+?)\s*(silent)?)?\s*$/; | 
| 13 | 11 |  | 50 |  |  | 68 | @{$self}{'source', 'destination', 'silent', 'sources', 'current_sources'} = ($1 // '', $2 // '', $3 // '', [], []); | 
|  | 11 |  | 100 |  |  | 36 |  | 
|  |  |  | 100 |  |  |  |  | 
| 14 | 11 |  |  |  |  | 32 | $self->{'sources'} = $self->parse_sources($self->{'source'}); | 
| 15 |  |  |  |  |  |  |  | 
| 16 | 11 |  |  |  |  | 15 | return $self; | 
| 17 |  |  |  |  |  |  | } | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | #@Override | 
| 20 |  |  |  |  |  |  | sub render | 
| 21 |  |  |  |  |  |  | { | 
| 22 | 53 |  |  | 53 | 0 | 43 | my( $self, $context, $global_safe) = @_; | 
| 23 | 53 |  |  |  |  | 36 | my $result = ''; | 
| 24 |  |  |  |  |  |  |  | 
| 25 | 53 |  |  |  |  | 56 | my $source = $self->get_next_source(); | 
| 26 | 53 |  |  |  |  | 84 | my $current_value = $source->render($context, $global_safe); | 
| 27 |  |  |  |  |  |  |  | 
| 28 | 53 | 100 |  |  |  | 75 | if( not $self->{'silent'} ) | 
| 29 |  |  |  |  |  |  | { | 
| 30 | 43 |  |  |  |  | 33 | $result = $current_value; | 
| 31 |  |  |  |  |  |  | } | 
| 32 |  |  |  |  |  |  |  | 
| 33 | 53 | 100 |  |  |  | 73 | if( $self->{'destination'} ) | 
| 34 |  |  |  |  |  |  | { | 
| 35 | 20 |  |  |  |  | 33 | $context->set( $self->{'destination'} => $current_value ); | 
| 36 |  |  |  |  |  |  | } | 
| 37 |  |  |  |  |  |  |  | 
| 38 | 53 |  |  |  |  | 114 | return $result; | 
| 39 |  |  |  |  |  |  | } | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | sub get_next_source | 
| 42 |  |  |  |  |  |  | { | 
| 43 | 53 |  |  | 53 | 0 | 36 | my $self = shift; | 
| 44 |  |  |  |  |  |  |  | 
| 45 | 53 | 100 |  |  |  | 33 | if( not scalar @{$self->{'current_sources'}} )    # populate for current cycle | 
|  | 53 |  |  |  |  | 79 |  | 
| 46 |  |  |  |  |  |  | { | 
| 47 | 18 |  |  |  |  | 11 | push @{$self->{'current_sources'}}, @{$self->{'sources'}}; | 
|  | 18 |  |  |  |  | 14 |  | 
|  | 18 |  |  |  |  | 25 |  | 
| 48 |  |  |  |  |  |  | } | 
| 49 |  |  |  |  |  |  |  | 
| 50 | 53 |  |  |  |  | 33 | return shift @{$self->{'current_sources'}}; | 
|  | 53 |  |  |  |  | 52 |  | 
| 51 |  |  |  |  |  |  | } | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | 1; |