This repository has been archived by the owner on Aug 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sass.ex
66 lines (50 loc) · 1.77 KB
/
sass.ex
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
defmodule Sass do
@moduledoc """
Compiles SASS into CSS using a NIF for Libsass
## Currently supported Sass options
* [output_style](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#output_style) `integer` - use the helpers below to assign the style
* precision `integer` - decimal rounding percision
* source_comments `true` or `false` - causes the line number and file where a selector is defined to be emitted into the compiled CSS as a comment
* soure_map_embed `true` or `false`
* source_map_contents `true` or `false`
* omit_source_map_url `true` or `false`
* is_indented_syntax `true` or `false`
* indent `:tab` or `:space`
* linefeed `:unix` or `:windows`
* include_paths `list` - list of directories for Sass to search for imports linked files. Example: `["bower_compoents", "../node_modules"]`
"""
alias Sass.Compiler
@doc """
Compiles a string of CSS/SCSS/Sass into CSS string
## Examples
iex> sass = "$white : #fff; a { color: $white;}"
iex> Sass.compile(sass)
{:ok, "a {\\n color: #fff; }\\n"}
# With options
iex> Sass.compile(sass, %{output_style: 2})
{:ok, "a { color: #fff; }\\n"}
"""
def compile(source, options \\ %{}) do
source
|> String.trim()
|> Compiler.compile(options)
end
@doc """
Compiles a file with CSS/SCSS/Sass into CSS string
## Examples
iex> Sass.compile_file("application.scss")
{:ok, "a {\\n color: #fff; }\\n"}
# With options
iex> Sass.compile_file("application.scss", %{output_style: 3})
{:ok, "a{color:#fff}\\n"}
"""
def compile_file(path, options \\ %{}) do
path
|> String.trim()
|> Compiler.compile_file(options)
end
@doc """
Prints version of LibSass
"""
def version, do: Compiler.version()
end