Sass
Inherits Reference / Object
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– DisablesourceMappingUrlin css output. - is_indented_syntax_src:
Bool– Treatsource_stringas 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@importdirective 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.
Constants
Constructors
Creates a new compiler. All options can be assigned as named arguments.
Class methods
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 methods
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.
Gets libsass option include_path.
Gets libsass option indent.
Gets libsass option input_path.
Gets libsass option is_indented_syntax_src.
Sets libsass option is_indented_syntax_src.
Gets libsass option linefeed.
Gets libsass option omit_source_map_url.
Sets libsass option omit_source_map_url.
Gets libsass option output_path.
Gets libsass option output_style.
Sets libsass option output_style.
Gets libsass option plugin_path.
Gets libsass option precision.
Sets libsass option precision.
Gets libsass option source_comments.
Sets libsass option source_comments.
Gets libsass option source_map_contents.
Sets libsass option source_map_contents.
Gets libsass option source_map_embed.
Sets libsass option source_map_embed.
Gets libsass option source_map_file.
Gets libsass option source_map_file_urls.
Sets libsass option source_map_file_urls.
Gets libsass option source_map_root.