| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Text::Sass::XS; |
|
2
|
7
|
|
|
7
|
|
270721
|
use 5.008005; |
|
|
7
|
|
|
|
|
28
|
|
|
|
7
|
|
|
|
|
285
|
|
|
3
|
7
|
|
|
7
|
|
38
|
use strict; |
|
|
7
|
|
|
|
|
15
|
|
|
|
7
|
|
|
|
|
252
|
|
|
4
|
7
|
|
|
7
|
|
41
|
use warnings; |
|
|
7
|
|
|
|
|
14
|
|
|
|
7
|
|
|
|
|
247
|
|
|
5
|
7
|
|
|
7
|
|
37
|
use base 'Exporter'; |
|
|
7
|
|
|
|
|
11
|
|
|
|
7
|
|
|
|
|
994
|
|
|
6
|
7
|
|
|
7
|
|
39
|
use Carp (); |
|
|
7
|
|
|
|
|
12
|
|
|
|
7
|
|
|
|
|
1171
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = "0.11"; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my @constants = qw( |
|
11
|
|
|
|
|
|
|
SASS_STYLE_NESTED |
|
12
|
|
|
|
|
|
|
SASS_STYLE_EXPANDED |
|
13
|
|
|
|
|
|
|
SASS_STYLE_COMPRESSED |
|
14
|
|
|
|
|
|
|
SASS_SOURCE_COMMENTS_NONE |
|
15
|
|
|
|
|
|
|
SASS_SOURCE_COMMENTS_DEFAULT |
|
16
|
|
|
|
|
|
|
SASS_SOURCE_COMMENTS_MAP |
|
17
|
|
|
|
|
|
|
); |
|
18
|
|
|
|
|
|
|
my @functions = qw( |
|
19
|
|
|
|
|
|
|
sass_compile |
|
20
|
|
|
|
|
|
|
sass_compile_file |
|
21
|
|
|
|
|
|
|
); |
|
22
|
|
|
|
|
|
|
our @EXPORT_OK = ( @constants, @functions ); |
|
23
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
|
24
|
|
|
|
|
|
|
'all' => [ @constants, @functions ], |
|
25
|
|
|
|
|
|
|
'const' => \@constants, |
|
26
|
|
|
|
|
|
|
'func' => \@functions |
|
27
|
|
|
|
|
|
|
); |
|
28
|
|
|
|
|
|
|
|
|
29
|
7
|
|
|
7
|
|
39
|
use XSLoader; |
|
|
7
|
|
|
|
|
26
|
|
|
|
7
|
|
|
|
|
6914
|
|
|
30
|
|
|
|
|
|
|
XSLoader::load( __PACKAGE__, $VERSION ); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub sass_compile { |
|
33
|
0
|
|
|
0
|
|
|
my $source_string = shift; |
|
34
|
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my $result; |
|
36
|
0
|
0
|
|
|
|
|
if (@_) { |
|
37
|
0
|
|
|
|
|
|
$result = _compile( $source_string, +{ _normalize_options(@_) } ); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
else { |
|
40
|
0
|
|
|
|
|
|
$result = _compile($source_string); |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
wantarray |
|
44
|
0
|
0
|
|
|
|
|
? ( $result->{output_string}, $result->{error_message} ) |
|
45
|
|
|
|
|
|
|
: $result->{output_string}; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub sass_compile_file { |
|
49
|
0
|
|
|
0
|
|
|
my $input_path = shift; |
|
50
|
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $result; |
|
52
|
0
|
0
|
|
|
|
|
if (@_) { |
|
53
|
0
|
|
|
|
|
|
$result = _compile_file( $input_path, +{ _normalize_options(@_) } ); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
else { |
|
56
|
0
|
|
|
|
|
|
$result = _compile_file($input_path); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
wantarray |
|
60
|
0
|
0
|
|
|
|
|
? ( $result->{output_string}, $result->{error_message} ) |
|
61
|
|
|
|
|
|
|
: $result->{output_string}; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub _normalize_options { |
|
65
|
0
|
0
|
|
0
|
|
|
return unless @_; |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
my %options = ref $_[0] eq 'HASH' ? %{ $_[0] } : @_; |
|
|
0
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# include_paths must be a colon separated string. |
|
70
|
0
|
0
|
0
|
|
|
|
if ( $options{include_paths} |
|
71
|
|
|
|
|
|
|
&& ref $options{include_paths} eq 'ARRAY' ) |
|
72
|
|
|
|
|
|
|
{ |
|
73
|
0
|
|
|
|
|
|
$options{include_paths} = join ':', @{ $options{include_paths} }; |
|
|
0
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
else { |
|
76
|
0
|
|
|
|
|
|
$options{include_paths} = ""; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
0
|
|
|
|
|
$options{image_path} = "" unless $options{image_path}; |
|
80
|
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
return %options; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# OO Interface |
|
85
|
|
|
|
|
|
|
sub new { |
|
86
|
0
|
|
|
0
|
|
|
my $class = shift; |
|
87
|
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
my $self = bless { |
|
89
|
|
|
|
|
|
|
options => { |
|
90
|
|
|
|
|
|
|
output_style => SASS_STYLE_COMPRESSED(), |
|
91
|
|
|
|
|
|
|
source_comments => SASS_SOURCE_COMMENTS_NONE(), |
|
92
|
|
|
|
|
|
|
include_paths => undef, |
|
93
|
|
|
|
|
|
|
image_path => undef, |
|
94
|
|
|
|
|
|
|
@_, |
|
95
|
|
|
|
|
|
|
}, |
|
96
|
|
|
|
|
|
|
_errstr => undef, |
|
97
|
|
|
|
|
|
|
}, $class; |
|
98
|
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
return $self; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub options { |
|
103
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
104
|
0
|
|
|
|
|
|
$self->{options}; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub errstr { |
|
108
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
109
|
0
|
0
|
|
|
|
|
if (@_) { |
|
110
|
0
|
|
|
|
|
|
$self->{_errstr} = shift; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
else { |
|
113
|
0
|
|
|
|
|
|
$self->{_errstr}; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub compile { |
|
118
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
119
|
0
|
|
|
|
|
|
my $source_string = shift; |
|
120
|
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
my %options = _normalize_options( %{ $self->options } ); |
|
|
0
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
my $result = _compile( $source_string, \%options ); |
|
123
|
|
|
|
|
|
|
|
|
124
|
0
|
0
|
|
|
|
|
if ( $result->{error_status} ) { |
|
125
|
0
|
|
|
|
|
|
Carp::croak $result->{error_message}; |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
else { |
|
128
|
0
|
|
|
|
|
|
return $result->{output_string}; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub compile_file { |
|
133
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
134
|
0
|
|
|
|
|
|
my $input_path = shift; |
|
135
|
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
my %options = _normalize_options( %{ $self->options } ); |
|
|
0
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
my $result = _compile_file( $input_path, \%options ); |
|
138
|
|
|
|
|
|
|
|
|
139
|
0
|
0
|
|
|
|
|
if ( $result->{error_status} ) { |
|
140
|
0
|
|
|
|
|
|
Carp::croak $result->{error_message}; |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
else { |
|
143
|
0
|
|
|
|
|
|
return $result->{output_string}; |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
# For Text::Sass Compatibility |
|
148
|
0
|
|
|
0
|
|
|
sub scss2css { shift->compile(@_) } |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub sass2css { |
|
151
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
152
|
0
|
|
|
|
|
|
$self->_require_pp; |
|
153
|
0
|
|
|
|
|
|
Text::Sass->new->sass2css(@_); |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub css2sass { |
|
157
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
158
|
0
|
|
|
|
|
|
$self->_require_pp; |
|
159
|
0
|
|
|
|
|
|
Text::Sass->new->css2sass(@_); |
|
160
|
|
|
|
|
|
|
} |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub _require_pp { |
|
163
|
0
|
0
|
|
0
|
|
|
return if $INC{"Text/Sass.pm"}; |
|
164
|
0
|
|
|
|
|
|
local $@; |
|
165
|
0
|
|
|
|
|
|
eval 'require Text::Sass;'; |
|
166
|
0
|
0
|
|
|
|
|
if ($@) { |
|
167
|
0
|
|
|
|
|
|
Carp::croak |
|
168
|
|
|
|
|
|
|
"Cannot load Text::Sass. If you want to use css2sass or sass2css method, you need to install Text::Sass first."; |
|
169
|
|
|
|
|
|
|
} |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
1; |
|
173
|
|
|
|
|
|
|
__END__ |