Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Import variables as JSON into Sass
Ruby

Readme improvement

I added note about reloading rails server. I hope it'll save a time of people.
latest commit f0d9ab3982
@Loremaster Loremaster authored

readme.md

Sass JSON Vars

Gitter

Build Status Coverage Status Code Climate Gem Version

@import json data into Sass $variables.

Important: the latest version of sass-rails is locked in to Sass 3.2. This means that Sass maps are not available to sass-json-vars to parse nested objects.

Usage

gem install sass-json-vars

After that reload rails server if you are on rails.

For projects using Sass >= 3.3

Place variables in a JSON file:

// variables.json
{
    "font-sans": "Helvetica, sans-serif",
    "colors": {
        "red": "#c33"
    }
}

Import the file in Sass to expose variable names:

@import "variables.json"

body {
    color: map-get($colors, red);
    font: $font-sans;
}

Require sass-json-vars when compiling

sass style.scss -r sass-json-vars

For projects using Sass <= 3.2

Place variables in a JSON file:

// variables.json
{
    "font-sans": "Helvetica, sans-serif",
    "colors-red": "#c33"
}

Import the file in Sass to expose variable names:

@import "variables.json"

body {
    color: $colors-red;
    font: $font-sans;
}

Require sass-json-vars when compiling

sass style.scss -r sass-json-vars
Something went wrong with that request. Please try again.