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


PHP lessc::compile方法代码示例

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


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

示例1: shoestrap_buttons_css

function shoestrap_buttons_css()
{
    $btn_color = get_theme_mod('shoestrap_buttons_color');
    // Make sure colors are properly formatted
    $btn_color = '#' . str_replace('#', '', $btn_color);
    // if no color has been selected, set to #0066cc. This prevents errors with the php-less compiler.
    if (strlen($btn_color) < 3) {
        $btn_color = '#0066cc';
    }
    ?>

  <style>
    <?php 
    if (class_exists('lessc')) {
        $less = new lessc();
        $less->setVariables(array("btnColor" => $btn_color));
        $less->setFormatter("compressed");
        if (shoestrap_get_brightness($btn_color) <= 160) {
            // The code below is a copied from bootstrap's buttons.less + mixins.less files
            echo $less->compile("\n          @btnColorHighlight: darken(spin(@btnColor, 5%), 10%);\n  \n          .gradientBar(@primaryColor, @secondaryColor, @textColor: #fff, @textShadow: 0 -1px 0 rgba(0,0,0,.25)) {\n            color: @textColor;\n            text-shadow: @textShadow;\n            #gradient > .vertical(@primaryColor, @secondaryColor);\n            border-color: @secondaryColor @secondaryColor darken(@secondaryColor, 15%);\n            border-color: rgba(0,0,0,.1) rgba(0,0,0,.1) fadein(rgba(0,0,0,.1), 15%);\n          }\n  \n          #gradient {\n            .vertical(@startColor: #555, @endColor: #333) {\n              background-color: mix(@startColor, @endColor, 60%);\n              background-image: -moz-linear-gradient(top, @startColor, @endColor); // FF 3.6+\n              background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@startColor), to(@endColor)); // Safari 4+, Chrome 2+\n              background-image: -webkit-linear-gradient(top, @startColor, @endColor); // Safari 5.1+, Chrome 10+\n              background-image: -o-linear-gradient(top, @startColor, @endColor); // Opera 11.10\n              background-image: linear-gradient(to bottom, @startColor, @endColor); // Standard, IE10\n              background-repeat: repeat-x;\n            }\n          }\n  \n          .buttonBackground(@startColor, @endColor, @textColor: #fff, @textShadow: 0 -1px 0 rgba(0,0,0,.25)) {\n            .gradientBar(@startColor, @endColor, @textColor, @textShadow);\n            *background-color: @endColor; /* Darken IE7 buttons by default so they stand out more given they won't have borders */\n            .reset-filter();\n            &:hover, &:active, &.active, &.disabled, &[disabled] {\n              color: @textColor;\n              background-color: @endColor;\n              *background-color: darken(@endColor, 5%);\n            }\n          }\n          .btn, .btn-primary{\n            .buttonBackground(@btnColor, @btnColorHighlight);\n          }\n        ");
        } else {
            echo $less->compile("\n          @btnColorHighlight: darken(@btnColor, 15%);\n  \n          .gradientBar(@primaryColor, @secondaryColor, @textColor: #333, @textShadow: 0 -1px 0 rgba(0,0,0,.25)) {\n            color: @textColor;\n            text-shadow: @textShadow;\n            #gradient > .vertical(@primaryColor, @secondaryColor);\n            border-color: @secondaryColor @secondaryColor darken(@secondaryColor, 15%);\n            border-color: rgba(0,0,0,.1) rgba(0,0,0,.1) fadein(rgba(0,0,0,.1), 15%);\n          }\n  \n          #gradient {\n            .vertical(@startColor: #555, @endColor: #333) {\n              background-color: mix(@startColor, @endColor, 60%);\n              background-image: -moz-linear-gradient(top, @startColor, @endColor); // FF 3.6+\n              background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@startColor), to(@endColor)); // Safari 4+, Chrome 2+\n              background-image: -webkit-linear-gradient(top, @startColor, @endColor); // Safari 5.1+, Chrome 10+\n              background-image: -o-linear-gradient(top, @startColor, @endColor); // Opera 11.10\n              background-image: linear-gradient(to bottom, @startColor, @endColor); // Standard, IE10\n              background-repeat: repeat-x;\n            }\n          }\n  \n          .buttonBackground(@startColor, @endColor, @textColor: #333, @textShadow: 0 -1px 0 rgba(0,0,0,.25)) {\n            .gradientBar(@startColor, @endColor, @textColor, @textShadow);\n            *background-color: @endColor; /* Darken IE7 buttons by default so they stand out more given they won't have borders */\n            .reset-filter();\n            &:hover, &:active, &.active, &.disabled, &[disabled] {\n              color: @textColor;\n              background-color: @endColor;\n              *background-color: darken(@endColor, 5%);\n            }\n          }\n          .btn, .btn-primary{\n            .buttonBackground(@btnColor, @btnColorHighlight);\n          }\n        ");
        }
    }
    ?>
  </style>
  <?php 
}
开发者ID:rhensley,项目名称:shoestrap,代码行数:28,代码来源:buttons.php

示例2: bigboom_generate_custom_color_scheme

/**
 * Generate custom color scheme css
 *
 * @since 1.0
 */
function bigboom_generate_custom_color_scheme()
{
    parse_str($_POST['data'], $data);
    if (!isset($data['custom_color_scheme'])) {
        return;
    }
    if (!$data['custom_color_scheme']) {
        return;
    }
    $color_1 = $data['custom_color_1'];
    if (!$color_1) {
        return;
    }
    // Prepare LESS to compile
    $less = file_get_contents(THEME_DIR . '/css/color-schemes/mixin.less');
    $less .= ".custom-color-scheme { .color-scheme({$color_1}); }";
    // Compile
    require THEME_DIR . '/inc/libs/lessc.inc.php';
    $compiler = new lessc();
    $compiler->setFormatter('compressed');
    $css = $compiler->compile($less);
    // Get file path
    $upload_dir = wp_upload_dir();
    $dir = path_join($upload_dir['basedir'], 'custom-css');
    $file = $dir . '/color-scheme.css';
    // Create directory if it doesn't exists
    wp_mkdir_p($dir);
    @file_put_contents($file, $css);
    wp_send_json_success();
}
开发者ID:Qualitair,项目名称:ecommerce,代码行数:35,代码来源:meta-boxes.php

示例3: compileStylesheet

	/**
	 * Compiles LESS stylesheets into one CSS-stylesheet and writes them
	 * to filesystem. Please be aware not to append '.css' within $filename!
	 * 
	 * @param	string			$filename
	 * @param	array<string>		$files
	 * @param	array<string>		$variables
	 * @param	string			$individualLess
	 * @param	wcf\system\Callback	$callback
	 */
	protected function compileStylesheet($filename, array $files, array $variables, $individualLess, Callback $callback) {
		// build LESS bootstrap
		$less = $this->bootstrap($variables);
		foreach ($files as $file) {
			$less .= $this->prepareFile($file);
		}
		
		// append individual CSS/LESS
		if ($individualLess) {
			$less .= $individualLess;
		}
		
		try {
			$content = $this->compiler->compile($less);
		}
		catch (\Exception $e) {
			throw new SystemException("Could not compile LESS: ".$e->getMessage(), 0, '', $e);
		}
		
		$content = $callback($content);
		
		// write stylesheet
		file_put_contents($filename.'.css', $content);
		
		// convert stylesheet to RTL
		$content = StyleUtil::convertCSSToRTL($content);
		
		// write stylesheet for RTL
		file_put_contents($filename.'-rtl.css', $content);
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:40,代码来源:StyleCompiler.class.php

示例4: jollyness_preprocess_html

function jollyness_preprocess_html(&$vars)
{
    //Process portfolio color
    if ($portfolio_category = taxonomy_vocabulary_machine_name_load('portfolio_category')) {
        $terms = taxonomy_get_tree($portfolio_category->vid);
        $less = new lessc();
        $css = '';
        $color = '';
        $class = '';
        foreach ($terms as $t) {
            $term = taxonomy_term_load($t->tid);
            $class = drupal_html_class($t->name);
            if (!empty($term->field_color)) {
                foreach ($term->field_color as $v) {
                    $color = $v[0]['value'];
                    break;
                }
            }
            if ($color) {
                $css .= ".dexp-masonry-filter,.dexp-portfolio-filter{.{$class} span:before{background-color: {$color} !important;}}";
                $css .= ".{$class} .portfolio-item-overlay{background-color: rgba(red({$color}), green({$color}), blue({$color}), 0.7) !important;}";
            }
        }
        $css = $less->compile($css);
        drupal_add_css($css, array('type' => 'inline'));
    }
}
开发者ID:antoniodltm,项目名称:pinolguitars,代码行数:27,代码来源:template.php

示例5: compile

 public static function compile($source, $path, $todir, $importdirs)
 {
     // call Less to compile
     $parser = new lessc();
     $parser->setImportDir(array_keys($importdirs));
     $parser->setPreserveComments(true);
     $output = $parser->compile($source);
     // update url
     $arr = preg_split(CANVASLess::$rsplitbegin . CANVASLess::$kfilepath . CANVASLess::$rsplitend, $output, -1, PREG_SPLIT_DELIM_CAPTURE);
     $output = '';
     $file = $relpath = '';
     $isfile = false;
     foreach ($arr as $s) {
         if ($isfile) {
             $isfile = false;
             $file = $s;
             $relpath = CANVASLess::relativePath($todir, dirname($file));
             $output .= "\n#" . CANVASLess::$kfilepath . "{content: \"{$file}\";}\n";
         } else {
             $output .= ($file ? CANVASPath::updateUrl($s, $relpath) : $s) . "\n\n";
             $isfile = true;
         }
     }
     return $output;
 }
开发者ID:shamsbd71,项目名称:canvas-framework,代码行数:25,代码来源:legacy.less.php

示例6: parse

 public static function parse($source, $isFile = true)
 {
     $parser = new lessc();
     try {
         return $isFile ? $parser->compileFile($source) : $parser->compile($source);
     } catch (Exception $e) {
         return '/** LESS PARSE ERROR: ' . $e->getMessage() . ' **/';
     }
 }
开发者ID:amdad,项目名称:portfolio,代码行数:9,代码来源:Less.php

示例7: compile

 public static function compile($source, $importdirs)
 {
     // call Less to compile
     $parser = new lessc();
     $parser->setImportDir(array_keys($importdirs));
     $parser->setPreserveComments(true);
     $output = $parser->compile($source);
     return $output;
 }
开发者ID:joshjim27,项目名称:jobsglobal,代码行数:9,代码来源:legacy.less.php

示例8: filterAssetFile

 /**
  * @param \AssetsBundle\AssetFile\AssetFile $oAssetFile
  * @return string
  */
 public function filterAssetFile(\AssetsBundle\AssetFile\AssetFile $oAssetFile)
 {
     $oLessParser = new \lessc();
     $oLessParser->addImportDir(getcwd());
     $oLessParser->setAllowUrlRewrite(true);
     //Prevent time limit errors
     set_time_limit(0);
     return trim($oLessParser->compile($oAssetFile->getAssetFileContents()));
 }
开发者ID:as-sar,项目名称:zf2-assets-bundle,代码行数:13,代码来源:LesscAssetFileFilter.php

示例9: compile

 /**
  * Compile the Less file in $origin to the CSS $destination file
  *
  * @param string $origin Input Less path
  * @param string $destination Output CSS path
  */
 public static function compile($origin, $destination)
 {
     $less = new \lessc();
     $less->indentChar = \Config::get('asset.indent_with');
     $less->setImportDir(array(dirname($origin), dirname($destination)));
     $raw_css = $less->compile(file_get_contents($origin));
     $destination = pathinfo($destination);
     \File::update($destination['dirname'], $destination['basename'], $raw_css);
 }
开发者ID:roine,项目名称:wawaw,代码行数:15,代码来源:lessphp.php

示例10: jetpack_less_css_preprocess

function jetpack_less_css_preprocess($less)
{
    require_once dirname(__FILE__) . '/preprocessors/lessc.inc.php';
    $compiler = new lessc();
    try {
        return $compiler->compile($less);
    } catch (Exception $e) {
        return $less;
    }
}
开发者ID:Nancers,项目名称:Snancy-Website-Files,代码行数:10,代码来源:preprocessors.php

示例11: compile

 /**
  * Compiles LESS code into CSS code using <em>lessphp</em>, http://leafo.net/lessphp
  * 
  * @param string $less Less code
  * @return string CSS code
  * @throws dmInvalidLessException
  */
 public function compile($less, array $importDirs = array())
 {
     $lessCompiler = new lessc();
     $lessCompiler->setImportDir($importDirs);
     try {
         return $lessCompiler->compile($less);
     } catch (Exception $e) {
         throw new dmInvalidLessException($e->getMessage());
     }
 }
开发者ID:runopencode,项目名称:diem-extended,代码行数:17,代码来源:dmLessAdapterPHP.class.php

示例12: buildString

 /**
  * Builds a LESS/CSS resource from string
  *
  * @param string $string
  *
  * @return type
  * The compiled and compressed CSS
  */
 public static function buildString($string)
 {
     $obj = new \lessc();
     $obj->setFormatter('compressed');
     try {
         $output = $obj->compile($string);
     } catch (\Exception $e) {
         throw $e;
     }
     return $output;
 }
开发者ID:apexstudios,项目名称:yamwlib,代码行数:19,代码来源:CssBuilder.php

示例13: compileTo

 /**
  * Compile all files into one file.
  *
  * @param string $filePath File location.
  * @param string $format   Formatter for less.
  *
  * @return void
  */
 public function compileTo($filePath, $format = 'compressed')
 {
     $less = '';
     foreach ($this->_files as $file) {
         $less .= file_get_contents($file) . "\n\n";
     }
     $this->_lessc->setImportDir($this->_importDirs);
     $this->_lessc->setFormatter($format);
     $result = $this->_lessc->compile($less);
     file_put_contents($filePath, $result);
 }
开发者ID:biggtfish,项目名称:cms,代码行数:19,代码来源:Less.php

示例14: lessphp

 /**
  * lessphp compiler
  * @link https://github.com/leafo/lessphp
  *
  * @param string $file
  *
  * @return string
  */
 protected function lessphp($file)
 {
     if (!class_exists('\\lessc')) {
         return Result::errorMissingPackage($this, 'lessc', 'leafo/lessphp');
     }
     $lessCode = file_get_contents($file);
     $less = new \lessc();
     if (isset($this->compilerOptions['importDirs'])) {
         $less->setImportDir($this->compilerOptions['importDirs']);
     }
     return $less->compile($lessCode);
 }
开发者ID:jjok,项目名称:Robo,代码行数:20,代码来源:Less.php

示例15: add_less

function add_less($file)
{
    $target = str_replace(".less", ".css", $file);
    if (!file_exists($target) || filemtime($file) > filemtime($target)) {
        $c = new \lessc();
        $res = $c->compile(file_get_contents($file));
        file_put_contents($target, $res);
    }
    ?>
<link type="text/css" rel="stylesheet" href="<?php 
    echo $target;
    ?>
" /><?php 
}
开发者ID:dubrowsky,项目名称:docland,代码行数:14,代码来源:header.php


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