NAME - perl bindings for libsass

CSS::Sass - Compile .scss files using libsass

SYNOPSIS

# Object Oriented API
use CSS::Sass;

# Call default constructor
my $sass = CSS::Sass->new;
# Manipulate options for compile calls
$sass->options->{source_comments} = 1;
# Call file compilation (may die on errors)
my $css = $sass->compile_file('styles.scss');

# Add custom function to use inside your Sass code
sub foobar { CSS::Sass::Value::String->new('blue') }
$sass->options->{sass_functions}->{'foobar'} = \ &foobar;

# Compile string and get css output and source-map json
$sass->options->{source_map_file} = 'output.css.map';
($css, $stats) = $sass->compile('A { color: foobar(); }');


# Object Oriented API w/ options
my $sass = CSS::Sass->new(plugin_paths    => ['plugins'],
                          include_paths   => ['some/include/path'],
                          output_style    => SASS_STYLE_COMPRESSED,
                          source_map_file => 'output.css.map',
                          source_comments => 1,
                          dont_die        => 1,
                          sass_functions  => {
                            'foobar($arg)' => sub { $_[0] }
                          });

# Compile string and use the registered function
my ($css, $stats) = $sass->compile('A { color: foobar(red); }');

# Result can be undef because 'dont_die' was set
warn $sass->last_error unless (defined $css);


# Functional API
use CSS::Sass qw(:Default sass_compile);

# Functional API, with error messages and source-map
my ($css, $err, $stats) = sass_compile('A { color: red; }');
die $err if defined $err;

# Functional API, simple, with no error messages
my $css = sass_compile('A { color: red; }');
die unless defined $css;

# Functional API w/ options
my ($css, $err, $stats) = sass_compile('A { color: red; }',
                                       include_paths   => ['some/include/path'],
                                       output_style    => SASS_STYLE_NESTED,
                                       source_map_file => 'output.css.map');

# Import sass2scss function
use CSS::Sass qw(sass2scss);

# convert indented syntax
my $scss = sass2scss($sass);

# Import quoting functions
use CSS::Sass qw(quote unquote);

# Exchange quoted strings
my $string = unquote($from_sass);
my $to_sass = quote($string, '"');

DESCRIPTION

CSS::Sass provides a perl interface to libsass, a fairly complete Sass compiler written in C++. It is currently around ruby sass 3.3/3.4 feature parity and heading towards full 3.4 compatibility. It can compile .scss and .sass files.

OBJECT ORIENTED INTERFACE

FUNCTIONAL INTERFACE

OPTIONS

MISCELLANEOUS

SEE ALSO

CSS::Sass::Value

The Sass Home Page

The libsass Home Page

The CSS::Sass Home Page

AUTHOR

David Caldwell <david@porkrind.org>
Marcel Greter <perl-libsass@ocbnet.ch>

LICENSE

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.