blob: ec72d6e58f09d86fcb499a42678fa25d45eea781 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# Embedded Sass Host for Ruby
[](https://github.com/sass-contrib/sass-embedded-host-ruby/actions/workflows/build.yml)
[](https://rubygems.org/gems/sass-embedded)
This is a Ruby library that implements the host side of the [Embedded Sass protocol](https://github.com/sass/sass/blob/HEAD/spec/embedded-protocol.md).
It exposes a Ruby API for Sass that's backed by a native [Dart Sass](https://sass-lang.com/dart-sass) executable on [supported hardware architectures and platforms](https://dart.dev/get-dart#system-requirements) or a Node.js Dart Sass executable everywhere else.
## Install
``` sh
gem install sass-embedded
```
## Usage
The Ruby API provides two entrypoints for compiling Sass to CSS.
- `Sass.compile` takes a path to a Sass file and return the result of compiling that file to CSS.
``` ruby
require 'sass-embedded'
result = Sass.compile('style.scss')
puts result.css
compressed = Sass.compile('style.scss', style: :compressed)
puts compressed.css
```
- `Sass.compile_string` takes a string that represents the contents of a Sass file and return the result of compiling that file to CSS.
``` ruby
require 'sass-embedded'
result = Sass.compile_string('h1 { font-size: 40px; }')
puts result.css
compressed = Sass.compile_string('h1 { font-size: 40px; }', style: :compressed)
puts compressed.css
```
See [rubydoc.info/gems/sass-embedded/Sass](https://rubydoc.info/gems/sass-embedded/Sass) for full API documentation.
---
Disclaimer: this is not an official Google product.
|