LearnBoost/stylus — pull request #784 by geddesign (2012-08-10 08:48:56+00:00)
Title: BIF for converting .json to Stylus variables

Sharing certain variables across JS and Stylus is crazy awesome. For example, store your media queries in queries.json, and bring them in with Stylus:

```
json("queries.json")

@media large
.main
width: 100%
```

And use the same variables in your JS:

```js
$.ajax({
url: 'queries.json',
method: 'GET',
dataType: 'JSON',
success: function(queries){
var query = window.matchMedia(queries.large);
handleChange(query); //initial match
query.addListener(handleChange.bind(this, query)); //on query match change
}
});

function handleChange(query){
if(query.matches){
//change img src to use large images
}
}
```

Reworked based on previous discussion (#781).

The [getUnit](https://github.com/geddesign/stylus/blob/master/lib/functions/index.js#L430) function is a result of `utils.coerce()` not turning a string like "10px" into a Unit, causing that fun `cannot perform 10px * 2` error. It might be useful elsewhere, let me know if you want it moved to `utils`.

Thanks!