peteboere/css-crush — Issue #18: Add a new method inline
Author: AnonSphere
Created: 2011-12-14 03:17:37+00:00
State: open

Besides file and tag there should be an option for inline display, as page speed and yslow recommends it for smaller css files:

/**
* Process host CSS file and return the compiled css
*
* @param string $file Absolute or relative path to the host CSS file
* @param mixed $options An array of options or null
* @param array $attributes An array of HTML attributes
* @return string HTML stylesheet or error message inside HTML comment
*/
public static function inline ( $file, $options = null, $attributes = array() ) {
$config = self::$config;
$file = self::file( $file, $options );
if ( !empty( $file ) ) {
// On success return the complete stylesheet
$attr_string = '';
foreach ( $attributes as $name => $value ) {
$value = htmlspecialchars( $value, ENT_COMPAT, 'UTF-8', false );
$attr_string .= " $name=\"$value\"";
}
return "" . file_get_contents( "$config->baseDir/" . self::$compileName ) . "\n";
}
else {
// Return an HTML comment with message on failure
$class = __CLASS__;
return "\n";
}
}