SassyCast is a simple API for type conversion in Sass. Read API documentation.
bower install sassy-cast
SassCast has a strict mode in which it will throw errors when failing to cast values (most notably to colors and numbers). You can enable strict-mode with:
In non-strict mode, when a value cannot be converted to a number, SassyCast will warn and return
0. You can change this value with:
In non-strict mode, when a value cannot be converted to a color, SassyCast will warn and return
transparent. You can change this value with:
Note that color formats are sometimes converted automatically by Sass depending on the type of syntaxe used (compressed, expanded, etc.). When casting a color to string, the resulting string can be different from the color input.
Huge thanks to Marc Mintel for his help.