class Sass
- Sass
- Reference
- Object
Overview
This compiler provides a simple API to compile Sass and SCSS with libsass
.
Usage examples:
require "sass"
# Compile a Sass/SCSS file:
css = Sass.compile_file("application.scss")
# Compile a Sass/SCSS file with options:
css = Sass.compile_file("application.sass", include_path: "includes")
# Compile a Sass/SCSS string:
css = Sass.compile("body { div { color: red; } }")
Re-use compiler with options:
compiler = Sass.new(include_path: "_scss")
compiler.compile_file("main.scss") # Compile file main.scss
compiler.compile(%(@import "helper";)) # Import file _scss/helper.scss or _scss/_helper.scss
Options
- precision:
Int32
– Precision for fractional numbers. - output_style:
OutputStyle
– Output style for the generated CSS code. - source_comments:
Bool
– Emit comments in the generated CSS indicating the corresponding source line. - source_map_embed:
Bool
– embed sourceMappingUrl as data uri. - source_map_contents:
Bool
– embed include contents in maps. - source_map_file_urls:
Bool
– create file urls for sources. - omit_source_map_url:
Bool
– DisablesourceMappingUrl
in css output. - is_indented_syntax_src:
Bool
– Treatsource_string
as sass (as opposed to scss) - input_path:
String
– The input path is used for source map generating. It can be used to define something with string compilation or to overload the input file path. It is set to"stdin"
for data contexts and to the input file on file contexts. - output_path:
String
– The output path is used for source map generating. LibSass will not write to this file, it is just used to create information in source-maps etc. - indent:
String
– String to be used for indentation. - linefeed:
String
– String to be used to for line feeds. - include_path:
String
– Colon-separated list of paths where@import
directive looks for include files (semicolon-separated on Windows). - plugin_path:
String
– Colon-separated list of paths for libsass plugins (semicolon-separated on Windows). - source_map_file:
String
– Path to source map file. Enables the source map generating used to createsourceMappingUrl
. - source_map_root:
String
– Directly inserted in source maps.
Please refer to the libsass
API documentation
for further details.
Defined in:
sass.crcompiler.cr
sass2scss.cr
Constant Summary
-
VERSION =
"0.4.0"
Constructors
Class Method Summary
-
.libsass_version
Returns the version of
libsass
as aString
-
.sass2scss(content : String, prettify = :allman_style, comments = :convert) : String
Converts a
String
with Sass code into SCSS.
Instance Method Summary
-
#compile(string)
Compiles a Sass/SCSS string to CSS as
String
. -
#compile_file(file)
Compiles a Sass/SCSS file to CSS as
String
. -
#include_path : String?
Gets
libsass
option#include_path
. -
#include_path=(value : String?)
Sets
libsass
option#include_path
. -
#indent : String?
Gets
libsass
option#indent
. -
#indent=(value : String?)
Sets
libsass
option#indent
. -
#input_path : String?
Gets
libsass
option#input_path
. -
#input_path=(value : String?)
Sets
libsass
option#input_path
. -
#is_indented_syntax_src : Bool?
Gets
libsass
option#is_indented_syntax_src
. -
#is_indented_syntax_src=(is_indented_syntax_src : Bool?)
Sets
libsass
option#is_indented_syntax_src
. -
#linefeed : String?
Gets
libsass
option#linefeed
. -
#linefeed=(value : String?)
Sets
libsass
option#linefeed
. -
#omit_source_map_url : Bool?
Gets
libsass
option#omit_source_map_url
. -
#omit_source_map_url=(omit_source_map_url : Bool?)
Sets
libsass
option#omit_source_map_url
. -
#options : Options
Returns all options.
-
#output_path : String?
Gets
libsass
option#output_path
. -
#output_path=(value : String?)
Sets
libsass
option#output_path
. -
#output_style : LibSass::SassOutputStyle?
Gets
libsass
option#output_style
. -
#output_style=(output_style : LibSass::SassOutputStyle?)
Sets
libsass
option#output_style
. -
#plugin_path : String?
Gets
libsass
option#plugin_path
. -
#plugin_path=(value : String?)
Sets
libsass
option#plugin_path
. -
#precision : Int32?
Gets
libsass
option#precision
. -
#precision=(precision : Int32?)
Sets
libsass
option#precision
. -
#source_comments : Bool?
Gets
libsass
option#source_comments
. -
#source_comments=(source_comments : Bool?)
Sets
libsass
option#source_comments
. -
#source_map_contents : Bool?
Gets
libsass
option#source_map_contents
. -
#source_map_contents=(source_map_contents : Bool?)
Sets
libsass
option#source_map_contents
. -
#source_map_embed : Bool?
Gets
libsass
option#source_map_embed
. -
#source_map_embed=(source_map_embed : Bool?)
Sets
libsass
option#source_map_embed
. -
#source_map_file : String?
Gets
libsass
option#source_map_file
. -
#source_map_file=(value : String?)
Sets
libsass
option#source_map_file
. -
#source_map_file_urls : Bool?
Gets
libsass
option#source_map_file_urls
. -
#source_map_file_urls=(source_map_file_urls : Bool?)
Sets
libsass
option#source_map_file_urls
. -
#source_map_root : String?
Gets
libsass
option#source_map_root
. -
#source_map_root=(value : String?)
Sets
libsass
option#source_map_root
.
Constructor Detail
Creates a new compiler. All options can be assigned as named arguments.
Class Method Detail
Converts a String
with Sass code into SCSS.
prettify takes the following values:
:minimized
: Write everything on one line (minimized
):lisp_style
: Add lf after opening bracket (lisp style
):otbs_style
: Add lf after opening and before closing bracket (1TBS style
):allman_style
: Add lf before/after opening and before closing (allman style
) (default)
comments takes these values:
:convert
: convert all comments to/
and/
delimiters (default):keep
: keep comments:strip
: strip all comments
Instance Method Detail
Compiles a Sass/SCSS string to CSS as String
.
For available options see class description.
Compiles a Sass/SCSS file to CSS as String
.
For available options see class description.
Sets libsass
option #is_indented_syntax_src
.
Sets libsass
option #source_map_file_urls
.