blib/lib/Template/Plugin/Filter/Scss.pm

filter: Statementstmt 88.2% 15 / 17 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 91.3% 21 / 23 SCAR 0.0
CC
1
Cov
88%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
↑ Summary Build »
1 package Template::Plugin::Filter::Scss;
2 2 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use Template::Plugin::Filter;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use base qw( Template::Plugin::Filter );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use CSS::Sass;
Subroutine BEGIN: called CC=1 SCAR=2.6
10  
11 our $VERSION = "0.01";
12  
13 sub init {
14 my ($self) = @_;
15 $self->install_filter('scss');
16 return $self;
17 }
18  
19 sub filter {
20 my ($self, $text) = @_;
21  
22 my %options = ();
23 if ($self->{ _CONFIG } && (ref($self->{ _CONFIG }) eq 'HASH')) {
24 if ($self->{ _CONFIG }->{include_paths}) {
25 $options{include_paths} = [$self->{ _CONFIG }->{include_paths}];
26 }
27 elsif ($self->{ _CONFIG }->{include_path}) {
28 $options{include_paths} = [$self->{ _CONFIG }->{include_path}];
29 }
30  
31 if ($self->{ _CONFIG }->{output_style}) {
32 $options{output_style} = SASS_STYLE_NESTED if uc($self->{ _CONFIG }->{output_style}) eq 'NESTED';
33 $options{output_style} = SASS_STYLE_COMPACT if uc($self->{ _CONFIG }->{output_style}) eq 'COMPACT';
34 $options{output_style} = SASS_STYLE_EXPANDED if uc($self->{ _CONFIG }->{output_style}) eq 'EXPANDED';
35 $options{output_style} = SASS_STYLE_COMPRESSED if uc($self->{ _CONFIG }->{output_style}) eq 'COMPRESSED';
36 }
37 }
38  
39 my $sass = CSS::Sass->new(%options);
40  
41 my ($css, $stats) = $sass->compile($text);
42 return $css;
43 }
44  
45  
46 1;
47 __END__
↑ Summary Build »