Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options documented. #90

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,90 @@ to CSS. To compile, use a `SassC::Engine`, e.g.:
SassC::Engine.new(sass, style: :compressed).render
```

Here is a more detailed example, which also produces a
[source-map](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k):

```ruby
template = File.read('styles/mystyle.scss')

options = { style: :compressed,
filename: 'mystyle.scss',
output_path: 'mystyle.css',
source_map_file: 'mystyle.css.map',
load_paths: ['styles'],
source_map_contents: true }

engine = SassC::Engine.new(template, options)

css = engine.render
File.write('styles/mystyle.css', css)

map = engine.source_map
File.write('styles/mystyle.css.map', map)
```

**Note**: If you want to use this library with Rails/Sprockets, check out
[sassc-rails](https://github.com/bolandrm/sassc-rails).

Additionally, you can use `SassC::Sass2Scss` to convert Sass syntax to Scss syntax.

### Options

Options can be set by passing an option-hash to `SassC::Engine.new` as shown in the examples above.

Available options are:

* **`:syntax`**
The syntax of the input file, `:sass` for the indented syntax
and `:scss` for the CSS-extension syntax.
Defaults to `:scss`.

* **`:style`**
Sets the style of the CSS-output.
Can be `:nested`, `:compact`, `:compressed`, or `:expanded`.
See the [SASS_REFERENCE](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#output_style)
for details.
Defaults to `:nested`.

* **`:filename`**
The name of the file being rendered.
This is used for reporting errors and to reference the main source-file in the _source-map_.
Defaults to `"stdin"`.

* **`:output_path`**
The path to which the CSS-output will be written to. This value will be used to reference
the generated CCS-file in the _source-map_.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the generated CSS-file in the source-map.

When no value is provided, the _libsass_ library will try to guess this value using the value given in `:filename`.

* **`:source_map_file`**
The URI of the _source-map_. This information will be written into the compiled CSS-file.
Omitting this information causes no _source-map_ to be generated at all.

* **`:load_paths`**
An array of filesystem-paths which should be searched for Sass-partials.

* **`:precision`**
Sets the precision factor used in numeric output.

* **`:source_map_contents`**
When set to _true_ the full source text will be included in the _source-map_.
Useful for debugging in situations where the server cannot access the original source files.

* **`:source_map_embed`**
Includes the _source-map_ as a [Data URI](https://en.wikipedia.org/wiki/Data_URI_scheme) into the generated CSS-file.
Note: for security reasons, newer versions of Chrome- (60+) and Firefox- (61+) browsers now block web-pages from navigating
to _data URIs_ so that this option has become rather obsolete.

* **`:omit_source_map_url`**
When set to _true_ no reference to the _source-map_ file will be emitted into the CSS-file.

* **`:line_comments`**
When set to _true_ causes the line number and filename of the source to be emitted into the compiled CSS-file.
Useful for debugging when the _source-map_ is not available.

* **`:quiet`**
When set to _true_ a call to `Engine.render` will not produce any output.

## Credits

This gem is maintained by [Ryan Boland](https://ryanboland.com)
Expand Down