The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Text::Sass::XS - Perl Binding for libsass

SYNOPSIS

# OO Interface
use Text::Sass::XS;
use Try::Tiny;

my $sass = Text::Sass::XS->new;

try {
    my $css = $sass->compile(".something { color: red; }");
}
catch {
    die $_;
};

# OO Interface with options
my $sass = Text::Sass::XS->new(
    include_paths   => ['path/to/include'],
    image_path      => '/images',
    output_style    => SASS_STYLE_COMPRESSED,
    source_comments => SASS_SOURCE_COMMENTS_NONE,
);
try {
    my $css = $sass->compile(".something { color: red; }");
}
catch {
    die $_;
};



# Compile from file.
my $sass = Text::Sass::XS->new;
my $css = $sass->compile_file("/path/to/foo.scss");

# with options.
my $sass = Text::Sass::XS->new(
    include_paths   => ['path/to/include'],
    image_path      => '/images',
    output_style    => SASS_STYLE_COMPRESSED,
    source_comments => SASS_SOURCE_COMMENTS_NONE,
);
my $css = $sass->compile_file("/path/to/foo.scss");



# Functional Interface
# export sass_compile, sass_compile_file and some constants
use Text::Sass::XS ':all';

my $sass = "your sass string here...";
my $options = {
    output_style    => SASS_STYLE_COMPRESSED,
    source_comments => SASS_SOURCE_COMMENTS_NONE,
    include_paths   => 'site/css:vendor/css',
    image_path      => '/images'
};
my ($css, $errstr) = sass_compile($sass, $options);
die $errstr if $errstr;

my $sass_filename = "/path/to/foo.scss";
my $options = {
    output_style    => SASS_STYLE_COMPRESSED,
    source_comments => SASS_SOURCE_COMMENTS_NONE,
    include_paths   => 'site/css:vendor/css',
    image_path      => '/images'
};

# In scalar context, sass_compile(_file)? returns css only.
my $css = sass_compile_file($sass_filename, $options);
print $css;



# Text::Sass compatible Interface
my $sass = Text::Sass::XS->new(%options);
my $css = $sass->scss2css($source);

# sass2css and css2sass are implemented by Text::Sass
my $css  = $sass->sass2css($source);
my $scss = $sass->css2sass($css);

DESCRIPTION

Text::Sass::XS is a Perl Binding for libsass.

libsass Project page

OO INTERFACE

FUNCTIONAL INTERFACE

EXPORT

Nothing to export.

EXPORT_OK

Funcitons

Constants

For $options->{output_style}.

For $options->{source_comments}.

EXPORT_TAGS

SEE ALSO

Text::Sass - Pure perl implementation.

CSS::Sass - Yet another libsass binding.

LICENSE

Text::Sass::XS

Copyright (C) 2013 Yoshihiro Sasaki.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

libsass

Copyright (C) 2012 by Hampton Catlin.

See libsass/LICENSE for more details.

AUTHOR

Yoshihiro Sasaki ysasaki@cpan.org