https://github.com/bep/golibsass
Easy to use Go bindings for LibSass.
https://github.com/bep/golibsass
Last synced: about 1 year ago
JSON representation
Easy to use Go bindings for LibSass.
- Host: GitHub
- URL: https://github.com/bep/golibsass
- Owner: bep
- License: mit
- Created: 2020-02-06T09:47:18.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-08-28T10:14:33.000Z (over 1 year ago)
- Last Synced: 2025-02-17T06:36:56.833Z (about 1 year ago)
- Language: C++
- Homepage:
- Size: 1.79 MB
- Stars: 19
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/bep/golibsass/actions?query=workflow:Test)
[](https://goreportcard.com/report/github.com/bep/golibsass)
[](https://github.com/sass/libsass)
[](https://codecov.io/gh/bep/golibsass)
[](https://godoc.org/github.com/bep/golibsass/libsass)
**Note:** LibSASS (the C++ library that this project wraps) is now deprecated. You may want to try https://github.com/bep/godartsass
The primary motivation for this project is to provide `SCSS` support to [Hugo](https://gohugo.io/). I welcome PRs with bug fixes. I will also consider adding functionality, but please raise an issue discussing it first.
If you need more functionality than this project can provide you may want to have a look at [go-libsass](https://github.com/wellington/go-libsass).
## Usage
A basic example (error handling omitted):
```go
transpiler, _ := libsass.New(libsass.Options{OutputStyle: libsass.CompressedStyle})
result, _ := transpiler.Execute(`
$font-stack: Helvetica, sans-serif;
$primary-color: #333;
body {
font: 100% $font-stack;
color: $primary-color;
}
`)
fmt.Println(result.CSS)
// Output: body{font:100% Helvetica,sans-serif;color:#333}
```
See the [GoDoc](https://godoc.org/github.com/bep/golibsass/libsass) for more options.
## Update LibSass version
This project embeds the [LibSASS](https://github.com/sass/libsass) source code as a Git subtree. To update:
1. Pull in the relevant LibSASS version, e.g. `./pull-libsass.sh 3.6.3`
2. Regenerate wrappers with `go generate ./gen`
3. Update the LibSass version badge above.
## Local development
Compiling C++ code isn' particulary fast; if you install libsass on your PC you can link against that, useful during development.
On a Mac you may do something like:
```bash
brew install --HEAD libsass
go test ./libsass -tags dev
```