Pure Go CSS Preprocessor
Go CSS
Clone or download
Latest commit 3967759 Oct 12, 2014
Permalink
Failed to load latest commit information.
cmd/gcss Update compile.go Sep 18, 2014
test Allow variables in the middle of a statement #8 Oct 9, 2014
.gitignore Add e2e_test.go Sep 16, 2014
LICENSE Initial commit Sep 4, 2014
Makefile Fix the race condition Sep 13, 2014
README.md Update README.md Oct 7, 2014
at_rule.go Update at_rule.go Sep 17, 2014
at_rule_test.go Fix tests Oct 12, 2014
comment.go Add comment.go Sep 16, 2014
comment_test.go Fix tests Oct 12, 2014
compile.go Refactor the type switch processings Oct 10, 2014
compile_test.go Fix tests Oct 12, 2014
context.go Add mixin_invocation.go Sep 15, 2014
context_test.go Implement a variable Sep 13, 2014
declaration.go Allow variables in the middle of a statement #8 Oct 9, 2014
declaration_test.go Fix tests Oct 12, 2014
doc.go Add files Sep 4, 2014
e2e_test.go Fix tests Oct 12, 2014
element.go Add comment.go Sep 16, 2014
element_base.go Refactor the type switch processings Oct 10, 2014
element_base_test.go Fix tests Oct 12, 2014
element_test.go Fix tests Oct 12, 2014
line.go Add comment.go Sep 16, 2014
line_test.go Fix tests Oct 12, 2014
mixin_declaration.go Update e2e_test.go Sep 16, 2014
mixin_declaration_test.go Fix tests Oct 12, 2014
mixin_invocation.go Add the mixin function Sep 15, 2014
mixin_invocation_test.go Fix tests Oct 12, 2014
parse.go Add comment.go Sep 16, 2014
parse_test.go Fix tests Oct 12, 2014
selector.go Refactor the type switch processings Oct 10, 2014
selector_test.go Fix tests Oct 12, 2014
variable.go Implement a variable Sep 13, 2014
variable_test.go Fix tests Oct 12, 2014
version.go Update version.go Oct 10, 2014
wercker.yml Update wercker.yml Oct 1, 2014
write.go Add Path function Sep 18, 2014
write_test.go Fix tests Oct 12, 2014

README.md

GCSS - Pure Go CSS Preprocessor

wercker status Build status Coverage Status GoDoc ![Gitter](https://badges.gitter.im/Join Chat.svg)

Overview

GCSS is a pure Go CSS preprocessor. This is inspired by Sass and Stylus.

Syntax

Variables

$base-font: Helvetica, sans-serif
$main-color: blue

body
  font: 100% $base-font
  color: $main-color

Nesting

nav
  ul
    margin: 0
    padding: 0

a
  color: blue
  &:hover
    color: red

Mixins

$border-radius($radius)
  -webkit-border-radius: $radius
  -moz-border-radius: $radius
  -ms-border-radius: $radius
  border-radius: $radius

.box
  $border-radius(10px)

Installation

$ go get -u github.com/yosssi/gcss/...

Compile from the Command-Line

$ gcss /path/to/gcss/file

or

$ cat /path/to/gcss/file | gcss > /path/to/css/file

Compile from Go programs

You can compile a GCSS file from Go programs by invoking the gcss.CompileFile function.

cssPath, err := gcss.CompileFile("path_to_gcss_file")

if err != nil {
	http.Error(w, err.Error(), http.StatusInternalServerError)
	return
}

http.ServeFile(w, r, cssPath)

You can invoke the gcss.Compile function instead of the gcss.CompileFile function. The gcss.Compile function takes io.Writer and io.Reader as a parameter, compiles the GCSS data which is read from the io.Reader and writes the result CSS data to the io.Writer. Please see the GoDoc for the details.

f, err := os.Open("path_to_gcss_file")

if err != nil {
	panic(err)
}

defer func() {
	if err := f.Close(); err != nil {
		panic(err)
	}
}()

n, err := gcss.Compile(os.Stdout, f)

Documentation

Syntax Highlightings

  • vim-gcss - Vim syntax highlighting for GCSS