当前位置: 首页>>代码示例>>PHP>>正文


PHP Less_Parser::parseFile方法代码示例

本文整理汇总了PHP中Less_Parser::parseFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Less_Parser::parseFile方法的具体用法?PHP Less_Parser::parseFile怎么用?PHP Less_Parser::parseFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Less_Parser的用法示例。


在下文中一共展示了Less_Parser::parseFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: filterLoad

 /**
  * Filters an asset after it has been loaded.
  *
  * @param  \Assetic\Asset\AssetInterface  $asset
  * @return void
  */
 public function filterLoad(AssetInterface $asset)
 {
     $max_nesting_level = ini_get('xdebug.max_nesting_level');
     $memory_limit = ini_get('memory_limit');
     if ($max_nesting_level && $max_nesting_level < 200) {
         ini_set('xdebug.max_nesting_level', 200);
     }
     if ($memory_limit && $memory_limit < 256) {
         ini_set('memory_limit', '256M');
     }
     $root = $asset->getSourceRoot();
     $path = $asset->getSourcePath();
     $dirs = array();
     $lc = new \Less_Parser(array('compress' => true));
     if ($root && $path) {
         $dirs[] = dirname($root . '/' . $path);
     }
     foreach ($this->loadPaths as $loadPath) {
         $dirs[] = $loadPath;
     }
     $lc->SetImportDirs($dirs);
     $url = parse_url($this->getRequest()->getUriForPath(''));
     $absolutePath = str_replace(public_path(), '', $root);
     if (isset($url['path'])) {
         $absolutePath = $url['path'] . $absolutePath;
     }
     $lc->parseFile($root . '/' . $path, $absolutePath);
     $asset->setContent($lc->getCss());
 }
开发者ID:cartalyst,项目名称:assetic-filters,代码行数:35,代码来源:LessphpFilter.php

示例2: process

 /**
  * @param string $sourceFilePath
  * @return string
  */
 public function process($sourceFilePath)
 {
     $options = ['relativeUrls' => false, 'compress' => $this->appState->getMode() !== State::MODE_DEVELOPER];
     try {
         $parser = new \Less_Parser($options);
         $parser->parseFile($sourceFilePath, '');
         return $parser->getCss();
     } catch (\Exception $e) {
         $messagePrefix = 'CSS compilation from LESS ';
         $this->logger->critical($messagePrefix . $e->getMessage());
         return $messagePrefix . $e->getMessage();
     }
 }
开发者ID:kid17,项目名称:magento2,代码行数:17,代码来源:Oyejorge.php

示例3: _initCompiler

 /**
  * @return \Less_Parser
  */
 protected function _initCompiler()
 {
     if ($this->_compiler) {
         return $this->_compiler;
     }
     $options = array('compress' => false, 'strictUnits' => false, 'strictMath' => false, 'relativeUrls' => true, 'cache_method' => false, 'sourceMap' => false, 'indentation' => '    ');
     if ($this->_isDebug()) {
         $options['sourceMap'] = true;
         $options['sourceMapRootpath'] = $this->_options->get('root_path');
         $options['sourceMapBasepath'] = $this->_options->get('root_path');
     }
     // Create compilier
     $this->_compiler = new \Less_Parser($options);
     $this->_compiler->Reset();
     // Global depends
     $mixins = $this->_options->get('autoload');
     foreach ($mixins as $mixin) {
         $this->_compiler->parseFile($mixin);
     }
     // Add custom vars
     $this->_compiler->ModifyVars((array) $this->_options->get('global_vars', []));
     // Set paths
     $importPaths = (array) $this->_options->get('import_paths', []);
     foreach ($importPaths as $fullPath => $relPath) {
         $this->setImportPath($fullPath, $relPath);
     }
     // Set cutsom functions
     $functions = (array) $this->_options->get('functions', [], 'arr');
     foreach ($functions as $name => $function) {
         $this->_compiler->registerFunction($name, $function);
     }
     return $this->_compiler;
 }
开发者ID:jbzoo,项目名称:less,代码行数:36,代码来源:Gpeasy.php

示例4: _compile

 /**
  * @param string $path
  * @return string
  */
 protected function _compile($path)
 {
     try {
         $this->_processor->parseFile($path, $this->_tpl->less);
         $resultCss = $this->_processor->getCss();
         return $resultCss;
     } catch (Exception $ex) {
         die('<strong>Less Error (JBlank):</strong><br/><pre>' . $ex->getMessage() . '</pre>');
     }
 }
开发者ID:Cheren,项目名称:JBlank,代码行数:14,代码来源:css.less.gpeasy.php

示例5: parse

 /**
  * Parse given css file with given vars.
  * 
  * @param  string $file
  * @param  array  $vars
  * 
  * @return string
  */
 public function parse($file, array $vars, $custom)
 {
     $this->parser->parseFile($this->app['base_dir'] . '/assets/less/vendor/bootstrap/' . $file . '.less', $this->app['base_url']);
     $this->parser->modifyVars($vars);
     $css = $this->parser->getCss();
     //parse custom less if any passed
     if ($custom) {
         $this->parser->reset();
         $customCss = $this->parser->parse($custom)->getCss();
     } else {
         $customCss = '';
     }
     return $css . $customCss;
 }
开发者ID:shomimn,项目名称:builder,代码行数:22,代码来源:Less.php

示例6: empty

 function compile_botstrap_less_adm($theme, $input, $output = '', $compress = false)
 {
     global $cfg;
     $output = empty($output) ? $input : $output;
     $output = $cfg['themes_dir'] . '/admin/' . $theme . '/css/' . $output . '.css';
     $input = $cfg['themes_dir'] . '/admin/' . $theme . '/less/' . $input . '.less';
     if (file_exists($output) && file_exists($input)) {
         $filetimecss = filemtime($output);
         $filetimeless = filemtime($input);
         //	cot_print('css', cot_date('datetime_full', $filetimecss), 'less', cot_date('datetime_full', $filetimeless), cot_date('datetime_full'), $filetimecss > $filetimeless);
         if ($filetimecss > $filetimeless) {
             return false;
         } else {
             unlink($output);
             //	cot_print("deleted");
         }
     }
     $options = array('relativeUrls' => false);
     if ($compress) {
         $options['compress'] = true;
     }
     $parser = new Less_Parser($options);
     $parser->SetImportDirs(array($cfg['themes_dir'] . '/admin/' . $theme . '/less' => $cfg['themes_dir'] . '/admin/' . $theme . '/less', $cfg['plugins_dir'] . "/bootstrap/bootstrap/less" => $cfg['plugins_dir'] . "/bootstrap/bootstrap/less"));
     $parser->parseFile($input);
     $css = $parser->getCss();
     if (!file_exists($cfg['themes_dir'] . '/admin/' . $theme . '/css')) {
         mkdir($cfg['themes_dir'] . '/admin/' . $theme . '/css');
     }
     file_put_contents($output, $css);
     return true;
 }
开发者ID:esclkm,项目名称:cot-admintheme-comaterial,代码行数:31,代码来源:comaterial.php

示例7: makeCSS

 /**
  * Make a css file compiled from the LESS files collection
  *
  * @param array $lessFiles LESS files structures array
  *
  * @return array
  */
 public function makeCSS($lessFiles)
 {
     $file = $this->makeLESSResourcePath($lessFiles);
     $path = $this->getCSSResource($lessFiles);
     $url = $this->getCSSResourceURL($path);
     $data = array('file' => $path, 'media' => 'screen', 'url' => $url);
     if ($this->needToCompileLessResource($lessFiles)) {
         try {
             $originalPath = $this->getCSSResource($lessFiles, true);
             if ($path != $originalPath && $this->getLESSResourceHash($lessFiles, true) && $this->getLESSResourceHash($lessFiles, true) == $this->calcLESSResourceHash($lessFiles) && \Includes\Utils\FileManager::isFileReadable($originalPath)) {
                 $content = \Includes\Utils\FileManager::read($originalPath);
             } else {
                 // Need recreate parser for every parseFile
                 $this->parser = new \Less_Parser($this->getLessParserOptions());
                 $this->parser->parseFile($file, '');
                 $this->parser->ModifyVars($this->getModifiedLESSVars($data));
                 $content = $this->prepareLESSContent($this->parser->getCss(), $path, $data);
                 $this->setLESSResourceHash($lessFiles);
             }
             \Includes\Utils\FileManager::mkdirRecursive(dirname($path));
             \Includes\Utils\FileManager::write($path, $content);
         } catch (\Exception $e) {
             \XLite\Logger::getInstance()->registerException($e);
             $data = null;
         }
     }
     return $data;
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:35,代码来源:LessParser.php

示例8: process

 /**
  * @param string $sourceFilePath
  * @return string
  */
 public function process($sourceFilePath)
 {
     $options = ['relativeUrls' => false, 'compress' => $this->appState->getMode() !== State::MODE_DEVELOPER];
     $parser = new \Less_Parser($options);
     $parser->parseFile($sourceFilePath, '');
     return $parser->getCss();
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:11,代码来源:Oyejorge.php

示例9: compileFile

 public function compileFile($fname, $outFname = null)
 {
     if (!is_readable($fname)) {
         throw new Exception('load error: failed to find ' . $fname);
     }
     $pi = pathinfo($fname);
     $oldImport = $this->importDir;
     $this->importDir = (array) $this->importDir;
     $this->importDir[] = realpath($pi['dirname']) . '/';
     $this->allParsedFiles = array();
     $this->addParsedFile($fname);
     $parser = new Less_Parser(array('sourceMap' => $this->sourceMap));
     $parser->SetImportDirs($this->getImportDirs());
     if (count($this->registeredVars)) {
         $parser->ModifyVars($this->registeredVars);
     }
     foreach ($this->libFunctions as $name => $func) {
         $parser->registerFunction($name, $func);
     }
     $parser->parseFile($fname);
     $out = $parser->getCss();
     $parsed = Less_Parser::AllParsedFiles();
     foreach ($parsed as $file) {
         $this->addParsedFile($file);
     }
     $this->importDir = $oldImport;
     if ($outFname !== null) {
         return file_put_contents($outFname, $out);
     }
     return $out;
 }
开发者ID:bradcrumb,项目名称:lesscompiler,代码行数:31,代码来源:LessCompiler.php

示例10: CompareFile

 /**
  * Compare the parser results with the expected css
  *
  */
 function CompareFile($expected_file)
 {
     $less_file = $this->TranslateFile($expected_file);
     $expected_css = trim(file_get_contents($expected_file));
     // Check with standard parser
     echo "\n  " . basename($expected_file);
     echo "\n    - Standard Compiler";
     $parser = new Less_Parser();
     $parser->parseFile($less_file);
     $css = $parser->getCss();
     $css = trim($css);
     $this->assertEquals($expected_css, $css);
     // Check with cache
     if ($this->cache_dir) {
         $options = array('cache_dir' => $this->cache_dir);
         $files = array($less_file => '');
         echo "\n    - Regenerating Cache";
         $css_file_name = Less_Cache::Regen($files, $options);
         $css = file_get_contents($this->cache_dir . '/' . $css_file_name);
         $css = trim($css);
         $this->assertEquals($expected_css, $css);
         // Check using the cached data
         echo "\n    - Using Cache";
         $css_file_name = Less_Cache::Get($files, $options);
         $css = file_get_contents($this->cache_dir . '/' . $css_file_name);
         $css = trim($css);
         $this->assertEquals($expected_css, $css);
     }
 }
开发者ID:Flesh192,项目名称:magento,代码行数:33,代码来源:FixturesTest.php

示例11: parse_less

function parse_less($filename, $file)
{
    global $less_file, $is_dev;
    $options = array();
    if ($is_dev) {
        $options['sourceMap'] = true;
        $options['sourceMapWriteTo'] = '../css/' . $file . '.map';
        $options['sourceMapURL'] = '../css/' . $file . '.map';
    } else {
        $options['compress'] = true;
    }
    $options['cache_dir'] = '../css_cache';
    try {
        $parser = new Less_Parser($options);
        $parser->parseFile($less_file, '../css/');
        ob_start();
        echo $parser->getCss();
        $css = ob_get_contents();
        ob_end_clean();
        header("Content-type: text/css");
        @file_put_contents('../css/' . $file . '.css', $css);
        return $css;
    } catch (Exception $e) {
        header("Content-type: text/css");
        echo '/* LESS ERROR : ' . "\n\n" . $e->getMessage() . "\n\n" . '*/';
        showError($file . '.less');
    }
}
开发者ID:CamilleBouliere,项目名称:LESS-PHP---Out-of-the-box,代码行数:28,代码来源:less_compiler.php

示例12: getFormDynamicStyle

 public function getFormDynamicStyle($id)
 {
     $this->lessParser->parseFile($this->getBaseDir() . '/assets/less/style.less');
     $styleSettings = SCFP()->getSettings()->getStyleSettings();
     $this->lessParser->ModifyVars(array('id' => $id, 'no_border' => !empty($styleSettings['no_border']) ? $styleSettings['no_border'] : '', 'border_size' => !empty($styleSettings['border_size']) ? $styleSettings['border_size'] : '', 'border_style' => !empty($styleSettings['border_style']) ? $styleSettings['border_style'] : '', 'border_color' => !empty($styleSettings['border_color']) ? $styleSettings['border_color'] : '', 'field_label_text_color' => !empty($styleSettings['field_label_text_color']) ? $styleSettings['field_label_text_color'] : '', 'field_label_marker_text_color' => !empty($styleSettings['field_label_marker_text_color']) ? $styleSettings['field_label_marker_text_color'] : '', 'field_text_color' => !empty($styleSettings['field_text_color']) ? $styleSettings['field_text_color'] : '', 'no_background' => !empty($styleSettings['no_background']) ? $styleSettings['no_background'] : '', 'background_color' => !empty($styleSettings['background_color']) ? $styleSettings['background_color'] : '', 'button_color' => !empty($styleSettings['button_color']) ? $styleSettings['button_color'] : '', 'text_color' => !empty($styleSettings['text_color']) ? $styleSettings['text_color'] : '', 'hover_button_color' => !empty($styleSettings['hover_button_color']) ? $styleSettings['hover_button_color'] : '', 'hover_text_color' => !empty($styleSettings['hover_text_color']) ? $styleSettings['hover_text_color'] : ''));
     return '<style type="text/css" >' . $this->lessParser->getCss() . '</style>';
 }
开发者ID:viralss,项目名称:sunglow-solution,代码行数:7,代码来源:SCFP.class.php

示例13: processContent

 /**
  * @inheritdoc
  * @throws ContentProcessorException
  */
 public function processContent(File $asset)
 {
     $path = $asset->getPath();
     try {
         $parser = new \Less_Parser(['relativeUrls' => false, 'compress' => $this->appState->getMode() !== State::MODE_DEVELOPER]);
         $content = $this->assetSource->getContent($asset);
         if (trim($content) === '') {
             return '';
         }
         $tmpFilePath = $this->temporaryFile->createFile($path, $content);
         gc_disable();
         $parser->parseFile($tmpFilePath, '');
         $content = $parser->getCss();
         gc_enable();
         if (trim($content) === '') {
             $errorMessage = PHP_EOL . self::ERROR_MESSAGE_PREFIX . PHP_EOL . $path;
             $this->logger->critical($errorMessage);
             throw new ContentProcessorException(new Phrase($errorMessage));
         }
         return $content;
     } catch (\Exception $e) {
         $errorMessage = PHP_EOL . self::ERROR_MESSAGE_PREFIX . PHP_EOL . $path . PHP_EOL . $e->getMessage();
         $this->logger->critical($errorMessage);
         throw new ContentProcessorException(new Phrase($errorMessage));
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:30,代码来源:Processor.php

示例14: getFile

 /**
  * @return string
  */
 public function getFile()
 {
     // TODO use caching from plugin instead of custom caching to avoid import errors
     // Create less parser
     $parser = new \Less_Parser();
     try {
         // Parse file using direct file path
         $parser->parseFile($this->file['path'], '/');
         // Turn less into css
         $contents = $parser->getCss();
         // get all parsed files
         $parsed_files = $parser::AllParsedFiles();
         // reformat to make them the same format as the scss result parsed files list
         $new_list = array();
         foreach ($parsed_files as $parse_file) {
             $new_list[$parse_file] = filemtime($parse_file);
         }
         // store the new list
         $this->cache->save($this->file['hash'] . "parsed_files", $new_list);
     } catch (\Exception $e) {
         return false;
     }
     // fix absolute paths
     $contents = str_replace(array('../'), str_replace(ROOT, "", dirname($this->file['path'])) . '/../', $contents);
     // return css
     return $contents;
 }
开发者ID:Crecket,项目名称:dependency-manager,代码行数:30,代码来源:Less.php

示例15: compile

 /**
  * Compile the asset and return true on success
  *
  * @throws \Exception
  */
 protected function compile()
 {
     require_once TL_ROOT . '/' . $this->getParserPath();
     $parser = new \Less_Parser();
     $parser->parseFile(TL_ROOT . '/' . $this->getSourceFile()->path);
     $file = $this->getTemporaryFile();
     $file->write($parser->getCss());
 }
开发者ID:codefog,项目名称:contao-assets_manager,代码行数:13,代码来源:LessAsset.php


注:本文中的Less_Parser::parseFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。