本文整理汇总了PHP中Less_Parser::SetOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP Less_Parser::SetOptions方法的具体用法?PHP Less_Parser::SetOptions怎么用?PHP Less_Parser::SetOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Less_Parser
的用法示例。
在下文中一共展示了Less_Parser::SetOptions方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compile
/**
* Convert LESS to CSS
* @param string $string
* @return string
*/
public static function compile($string)
{
self::init();
$parser = new \Less_Parser();
$parser->SetOptions(['compress' => !Debugger::isEnabled()]);
$parser->parse($string);
return $parser->getCss();
}
示例2: less
/**
* less compiler
* @link https://github.com/oyejorge/less.php
*
* @param string $file
*
* @return string
*/
protected function less($file)
{
if (!class_exists('\\Less_Parser')) {
return Result::errorMissingPackage($this, 'Less_Parser', 'oyejorge/less.php');
}
$lessCode = file_get_contents($file);
$parser = new \Less_Parser();
$parser->SetOptions($this->compilerOptions);
if (isset($this->compilerOptions['importDirs'])) {
$importDirs = [];
foreach ($this->compilerOptions['importDirs'] as $dir) {
$importDirs[$dir] = $dir;
}
$parser->SetImportDirs($importDirs);
}
$parser->parse($lessCode);
return $parser->getCss();
}
示例3: read
public function read()
{
parent::read();
if (!$this->is_cached()) {
if (class_exists('\\Less_Parser')) {
$parser = new \Less_Parser();
$parser->SetOptions(array('compress' => $this->minify));
try {
$parser->parse($this->content);
} catch (\Exception $e) {
throw new \System\Error\Format(sprintf('Error while parsing LESS styles: %s', $e->getMessage()));
}
$this->content = $parser->getCss();
} else {
throw new \System\Error\MissingDependency('Missing less parser. Please install oyejorge/less.php');
}
}
}
示例4: handleScssLess
/**
* Handle SCSS/LESS files
*
* @param string $content The file content
* @param array $arrFile The file array
*
* @return string The modified file content
*/
protected function handleScssLess($content, $arrFile)
{
if ($arrFile['extension'] == self::SCSS) {
$objCompiler = new Compiler();
$objCompiler->setImportPaths(array(TL_ROOT . '/' . dirname($arrFile['name']), TL_ROOT . '/vendor/contao-components/compass/css'));
$objCompiler->setFormatter(\Config::get('debugMode') ? 'Leafo\\ScssPhp\\Formatter\\Expanded' : 'Leafo\\ScssPhp\\Formatter\\Compressed');
return $this->fixPaths($objCompiler->compile($content), $arrFile);
} else {
$strPath = dirname($arrFile['name']);
$arrOptions = array('strictMath' => true, 'compress' => !\Config::get('debugMode'), 'import_dirs' => array(TL_ROOT . '/' . $strPath => $strPath));
$objParser = new \Less_Parser();
$objParser->SetOptions($arrOptions);
$objParser->parse($content);
return $this->fixPaths($objParser->getCss(), $arrFile);
}
}
示例5: setConfiguration
/**
* Allows to set different configurations for the less compiler,
* like the compress mode or css source maps.
*
* @param array $configuration
* @return void
*/
public function setConfiguration(array $configuration)
{
$this->compiler->SetOptions($configuration);
}