Input formats

JavaScript

Just create a .js file like for example /css/styles.js. The file should contain the usual nodejs module code.

module.exports = function(api) {
    // use the Absurd's api here
}

JSON

The library supports importing of pure JSON. Of course this approach doesn't give you an access to the API, but it is still useful if you want to skip the typical Nodejs module definition.

// styles.json
{
    "body": {
        "margin": "0",
        "padding": "0",
        "fontSize": "1em",
        "p": {
            "line-height": "30px"
        }
    }
}

// app.js
Absurd("styles.json").compile(function(err, css) {
    // ...
});

CSS

Absurd accepts normal CSS. The good news is that you can still use all the other features.

// styles.js
api.plugin("size", function(api, type) {
    switch(type) {
        case "large": return { fontSize: "30px" }; break;
        case "medium": return { fontSize: "24px" }; break;
        case "small": return { fontSize: "12px" }; break;
        default: return { fontSize: "16px" };
    }
});
api.import(__dirname + "/css/main.css");

// main.css
body {
    margin-top: 10px;
    size: small;
}

And the result is:

body {
    margin-top: 10px;
    font-size: 12px;
}

YAML

The library supports import of YAML files

// styles.yaml
---
body:
  margin: 0
  padding: 0
  fontSize: 1em
  p:
    line-height: 30px

// app.js
Absurd("styles.yaml").compile(function(err, css) {
    // ...
});