source: code/trunk/vendor/github.com/yosssi/gcss/README.md@ 67

Last change on this file since 67 was 67, checked in by Izuru Yakumo, 23 months ago

Use vendored modules

Signed-off-by: Izuru Yakumo <yakumo.izuru@…>

File size: 2.5 KB
Line 
1# GCSS - Pure Go CSS Preprocessor
2
3[![wercker status](https://app.wercker.com/status/4857161fd705e6c43df492e6a33ce87f/m "wercker status")](https://app.wercker.com/project/bykey/4857161fd705e6c43df492e6a33ce87f)
4[![Build status](https://ci.appveyor.com/api/projects/status/ocbu6upgr3j0m3vc/branch/master)](https://ci.appveyor.com/project/yosssi/gcss/branch/master)
5[![Coverage Status](https://img.shields.io/coveralls/yosssi/gcss.svg)](https://coveralls.io/r/yosssi/gcss?branch=master)
6[![GoDoc](http://godoc.org/github.com/yosssi/gcss?status.svg)](http://godoc.org/github.com/yosssi/gcss)
7[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/yosssi/gcss?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
8
9## Overview
10
11GCSS is a pure Go CSS preprocessor. This is inspired by [Sass](http://sass-lang.com/) and [Stylus](http://learnboost.github.io/stylus/).
12
13## Syntax
14
15### Variables
16
17```scss
18$base-font: Helvetica, sans-serif
19$main-color: blue
20
21body
22 font: 100% $base-font
23 color: $main-color
24```
25
26### Nesting
27
28```scss
29nav
30 ul
31 margin: 0
32 padding: 0
33
34a
35 color: blue
36 &:hover
37 color: red
38```
39
40### Mixins
41
42```scss
43$border-radius($radius)
44 -webkit-border-radius: $radius
45 -moz-border-radius: $radius
46 -ms-border-radius: $radius
47 border-radius: $radius
48
49.box
50 $border-radius(10px)
51```
52
53## Installation
54
55```sh
56$ go get -u github.com/yosssi/gcss/...
57```
58
59## Compile from the Command-Line
60
61```sh
62$ gcss /path/to/gcss/file
63```
64
65or
66
67```sh
68$ cat /path/to/gcss/file | gcss > /path/to/css/file
69```
70
71## Compile from Go programs
72
73You can compile a GCSS file from Go programs by invoking the `gcss.CompileFile` function.
74
75```go
76cssPath, err := gcss.CompileFile("path_to_gcss_file")
77
78if err != nil {
79 http.Error(w, err.Error(), http.StatusInternalServerError)
80 return
81}
82
83http.ServeFile(w, r, cssPath)
84```
85
86You 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](http://godoc.org/github.com/yosssi/gcss) for the details.
87
88```go
89f, err := os.Open("path_to_gcss_file")
90
91if err != nil {
92 panic(err)
93}
94
95defer func() {
96 if err := f.Close(); err != nil {
97 panic(err)
98 }
99}()
100
101n, err := gcss.Compile(os.Stdout, f)
102```
103
104## Documentation
105
106* [GoDoc](http://godoc.org/github.com/yosssi/gcss)
107
108## Syntax Highlightings
109
110* [vim-gcss](https://github.com/yosssi/vim-gcss) - Vim syntax highlighting for GCSS
Note: See TracBrowser for help on using the repository browser.