function lessc::unit in Less CSS Preprocessor 6.3
Same name and namespace in other branches
- 6 lessc.inc.php \lessc::unit()
1 call to lessc::unit()
- lessc::value in lessphp/
lessc.inc.php
File
- lessphp/
lessc.inc.php, line 483
Class
Code
function unit(&$unit, $allowed = null) {
$simpleCase = $allowed == null;
if (!$allowed) {
$allowed = self::$units;
}
if ($this
->match('(-?[0-9]*(\\.)?[0-9]+)(' . implode('|', $allowed) . ')?', $m, !$simpleCase)) {
if (!isset($m[3])) {
$m[3] = 'number';
}
$unit = array(
$m[3],
$m[1],
);
// check for size/height font unit.. should this even be here?
if ($simpleCase) {
$s = $this
->seek();
if ($this
->literal('/', false) && $this
->unit($right, self::$units)) {
$unit = array(
'keyword',
$this
->compileValue($unit) . '/' . $this
->compileValue($right),
);
}
else {
// get rid of whitespace
$this
->seek($s);
$this
->match('', $_);
}
}
return true;
}
return false;
}