File Coverage

blib/lib/Moonshine/Bootstrap/Component/BasicTemplate.pm
Criterion Covered Total %
statement 17 17 100.0
branch n/a
condition 1 2 50.0
subroutine 4 4 100.0
pod n/a
total 22 23 95.6


line stmt bran cond sub pod time code
1             package Moonshine::Bootstrap::Component::BasicTemplate;
2              
3 5     5   258743 use Moonshine::Magic;
  5         148862  
  5         61  
4 5     5   3013 use Params::Validate qw/ARRAYREF/;
  5         15  
  5         419  
5 5     5   34 use Moonshine::Util;
  5         14  
  5         86  
6              
7             lazy_components qw/head meta link script body title/;
8             extends 'Moonshine::Bootstrap::Component';
9              
10             has(
11             basic_template_spec => sub {
12             {
13             tag => { default => 'html' },
14             lang => { default => 'en' },
15             header => { default => [ ], type => ARRAYREF },
16             body => { default => [ ], type => ARRAYREF },
17             };
18             }
19             );
20              
21             sub basic_template {
22 5     5   31815 my ($self) = shift;
23              
24 5   50     39 my ( $base_args, $build_args ) = $self->validate_build(
25             {
26             params => $_[0] // {},
27             spec => $self->basic_template_spec,
28             }
29             );
30              
31 5         41 unshift @{ $build_args->{header} }, (
  5         52  
32             {
33             action => 'meta',
34             charset => 'utf-8',
35             },
36             {
37             action => 'meta',
38             http_equiv => 'X-UA-Compatible',
39             content => 'IE=edge',
40             },
41             {
42             action => 'meta',
43             name => 'viewport',
44             content => 'width=device-width, inline-scale=1',
45             },
46             );
47              
48 5         37 my $base_element = Moonshine::Element->new($base_args);
49            
50 5         10940 $base_element->add_child( $self->head({ children => $build_args->{header} }) );
51 5         10499 $base_element->add_child( $self->body({ children => $build_args->{body} }) );
52              
53 5         10515 return $base_element;
54             }
55              
56             1;
57              
58             __END__