lua-sass
Lua bindings for libsass.
Requirements
Installation
luarocks install sass
Usage
The sass
module provides 2 functions, which are named in accordance with
their libsass counterparts:
compile
local css, err = sass.compile(scss, style)
Parameters:
scss
: A string of SCSS input text.style
: The output style. Either"nested"
or"compressed"
(optional; defaults to"nested"
).
Returns:
Either a string of CSS on success, or nil
and an error message on failure.
compile_file
local css, err = sass.compile_file(filename, style)
Parameters:
filename
: An SCSS file to read input from.- As above.
Returns:
As above.
Examples
Compiling a string and using the assert
idiom for error handling:
local sass = require "sass"
local css = assert(sass.compile "$x: red; div {color: $x}")
print(css)
Compiling a file and using explicit error handling:
local sass = require "sass"
local css, err = sass.compile_file("file.scss", "nested")
if css then
io.stdout:write(css)
else
io.stderr:write(err)
os.exit(1)
end