Gerillass

v2.1.0

Convert To Number

Type: Function
convertToNumber();

Parses a string of digits into a number.

Arguments

NameTypeDescription
$valuestringAccepts a string containing only digits.

Examples

A numeric string turned into a number you can do arithmetic with.

Sass
.column {
  width: convertToNumber("50") * 1%;
}
CSS
.column {
  width: 50%;
}

What it refuses

Arguments are checked, so a wrong value stops the build with a message instead of quietly producing the wrong CSS.

Sass
.column {
  width: convertToNumber(50) * 1%;
}
Error: `50` is not a valid $value for `convertToNumber`. Pass a string made only of digits, such as `"42"`.