Skip to content

Instantly share code, notes, and snippets.

@roborourke
Created September 25, 2012 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roborourke/3783815 to your computer and use it in GitHub Desktop.
Save roborourke/3783815 to your computer and use it in GitHub Desktop.
lesscss-parser erro workaround
<?php
$lessc = new lessc();
$lessc->registerFunction('foo', function($arg) {
list($type, $delimiter, $values) = $arg;
// $values is not flat array when using variables within arguments
// We cannot easily read the compiled value
$string = 'mod-';
if ( is_array( $values ) ) {
foreach( $values as $value ) {
if ( is_string( $value ) ) $string .= $value;
if ( is_array( $value ) && $value[0] == 'string' ) $string .= implode( ' ', $value[2] );
}
}
print_r($values);
return array($type, $delimiter, (array)$string);
});
$css = <<<EOD
@bar: ~"something";
.selector {
src: foo('boom.eot');
src: foo('@{bar}.eot');
}
EOD;
echo $lessc->parse($css);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment