sass

package module
v0.0.0-...-0a0e6d3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2026 License: BSD-3-Clause Imports: 1 Imported by: 0

README

go-ruby-sass/sass

CI Go Reference

A thin Ruby-facing adapter over the pure-Go, CGO-free Sass/SCSS compiler github.com/go-scss/scss. It exposes the modern sass-embedded gem surface (and the legacy sassc surface) in a shape the rbgo binding wraps directly, so pure-Go Ruby can compile Sass with no cgo and no external sass binary.

All language work and the dart-sass differential gate live in go-scss/scss; this module only maps Ruby keyword arguments to the engine's typed options and returns a result mirroring the gem's Sass::CompileResult.

Gem API surface

sass-embedded (Sass)
import sass "github.com/go-ruby-sass/sass"

// Sass.compile_string(source, syntax:, style:, load_paths:, importer:)
res, err := sass.CompileString(src, &sass.Options{
    Syntax:    sass.SyntaxSCSS,       // scss | indented | css
    Style:     sass.StyleCompressed,  // expanded | compressed
    LoadPaths: []string{"_sass"},
})
_ = res.CSS          // => css
_ = res.LoadedURLs   // => loaded_urls
_ = res.SourceMap    // => source_map (empty; see engine residuals)

// Sass.compile(path, ...)
res, err = sass.Compile("styles/main.scss", nil)

CompileString is the exact entry point Jekyll's jekyll-sass-converter calls — that path is covered by a dedicated test.

sassc (SassC::Engine)
import "github.com/go-ruby-sass/sass/sassc"

// SassC::Engine.new(template, style: :compressed).render
css, err := sassc.NewEngine(template, sassc.EngineOptions{
    Style: sassc.StyleCompressed,
}).Render()

Ruby mapping (for the rbgo binding)

Ruby Go
Sass.compile_string(src, **kw) sass.CompileString(src, opts)
Sass.compile(path, **kw) sass.Compile(path, opts)
result .css / .loaded_urls / .source_map CompileResult.CSS / .LoadedURLs / .SourceMap
syntax: / style: / load_paths: Options.Syntax / .Style / .LoadPaths
custom importer Options.Importer func(url) (src, canonical, ok)
SassC::Engine.new(t, style:).render sassc.NewEngine(t, opts).Render()

Residuals

  • source_map is not yet emitted (the engine does not produce source maps yet).
  • sassc :nested/:compact styles fall back to expanded (the engine emits expanded and compressed).
  • Output fidelity is exactly that of the underlying engine — see the go-scss/scss residuals (notably CSS Color 4 percentage serialization for some computed colors).

License

BSD-3-Clause. Copyright (c) 2026, the go-ruby-sass/sass authors.

Documentation

Overview

Package sass is a thin Ruby-facing adapter over the pure-Go Sass/SCSS compiler github.com/go-scss/scss. It exposes the modern sass-embedded gem surface — Sass.compile_string(source, syntax:, style:, load_paths:, ...) and Sass.compile(path, ...) returning {css, loaded_urls, source_map} — in a shape the rbgo binding wraps directly, plus the legacy SassC::Engine API (see the sassc subpackage).

This module is intentionally minimal: it maps Ruby keyword arguments to the engine's typed options, calls the engine, and returns a result whose fields mirror the gem's CompileResult (`css`, `loaded_urls`, `source_map`).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompileResult

type CompileResult struct {
	CSS        string
	LoadedURLs []string
	SourceMap  string
}

CompileResult mirrors the gem's Sass::CompileResult: css, loaded_urls, and source_map (source maps are not yet emitted; see the engine residuals).

func Compile

func Compile(path string, opts *Options) (*CompileResult, error)

Compile compiles a Sass/SCSS file, mirroring Sass.compile.

func CompileString

func CompileString(source string, opts *Options) (*CompileResult, error)

CompileString compiles Sass/SCSS source text, mirroring Sass.compile_string. This is the entry point Jekyll's jekyll-sass-converter calls.

type Options

type Options struct {
	// Syntax is honored by CompileString; Compile infers it from the file
	// extension unless overridden.
	Syntax    Syntax
	Style     Style
	LoadPaths []string
	// Importer, when non-nil, resolves @use/@forward/@import URLs. It mirrors a
	// custom Ruby importer: given a URL it returns the source, a canonical URL,
	// and whether it handled the request.
	Importer func(url string) (source string, canonicalURL string, ok bool)
}

Options mirrors the sass-embedded keyword arguments common to compile and compile_string. Zero values match the gem defaults (SCSS, expanded).

type Style

type Style string

Style mirrors the gem's `style:` keyword ("expanded", "compressed").

const (
	StyleExpanded   Style = "expanded"
	StyleCompressed Style = "compressed"
)

type Syntax

type Syntax string

Syntax mirrors the gem's `syntax:` keyword ("scss", "indented", "css").

const (
	SyntaxSCSS     Syntax = "scss"
	SyntaxIndented Syntax = "indented"
	SyntaxCSS      Syntax = "css"
)

Directories

Path Synopsis
Package sassc mirrors the legacy SassC gem surface — SassC::Engine.new( template, style:).render — layered over the same pure-Go engine, since real applications still use both the modern sass-embedded and the older sassc API.
Package sassc mirrors the legacy SassC gem surface — SassC::Engine.new( template, style:).render — layered over the same pure-Go engine, since real applications still use both the modern sass-embedded and the older sassc API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL