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


PHP scssc::setNumberPrecision方法代码示例

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


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

示例1: compile

 public function compile()
 {
     // go on even if user "stops" the script by closing the browser, closing the terminal etc.
     ignore_user_abort(true);
     // set script running time to unlimited
     set_time_limit(0);
     $root_dir = $this->root_dir;
     $scss_compiler = new scssc();
     $scss_compiler->setNumberPrecision(10);
     $scss_compiler->stripComments = $this->strip_comments;
     $scss_compiler->addImportPath(function ($path) use($root_dir) {
         $path = $root_dir . $path . '.scss';
         $path_parts = pathinfo($path);
         $underscore_file = $path_parts['dirname'] . '/_' . $path_parts['basename'];
         if (file_exists($underscore_file)) {
             $path = $underscore_file;
         }
         if (!file_exists($path)) {
             return null;
         }
         return $path;
     });
     // set the path to your to-be-imported mixins. please note: custom paths are coming up on future releases!
     //$scss_compiler->setImportPaths($scss_folder);
     // set css formatting (normal, nested or minimized), @see http://leafo.net/scssphp/docs/#output_formatting
     $scss_compiler->setFormatter($this->formatter);
     // get .scss's content, put it into $string_sass
     $string_sass = '';
     if (is_array($this->scss_file)) {
         foreach ($this->scss_file as $scss_file) {
             $string_sass .= file_get_contents($scss_file);
         }
     } else {
         $string_sass = file_get_contents($this->scss_file);
     }
     // try/catch block to prevent script stopping when scss compiler throws an error
     try {
         // compile this SASS code to CSS
         $string_css = $scss_compiler->compile($string_sass) . "\n";
         // $string_css = csscrush_string($string_css, $options = array('minify' => true));
         // write CSS into file with the same filename, but .css extension
         file_put_contents($this->css_file, $string_css);
     } catch (Exception $e) {
         // here we could put the exception message, but who cares ...
         echo $e->getMessage();
         exit;
     }
 }
开发者ID:staabm,项目名称:redaxo,代码行数:48,代码来源:scss_compiler.php

示例2: alfath_custom_css_compiler

function alfath_custom_css_compiler($options)
{
    global $wp_filesystem;
    if (empty($wp_filesystem)) {
        require_once ABSPATH . '/wp-admin/includes/file.php';
        WP_Filesystem();
    }
    if (!class_exists('scssc')) {
        require_once ADMIN_DIR . '/option/configs/scss.inc.php';
    }
    $scssc = new scssc();
    $scssc->setImportPaths(get_template_directory() . '/assets/sass/');
    $scssc->setNumberPrecision(10);
    $file = get_template_directory() . '/assets/sass/custom.scss';
    $target = get_template_directory() . '/assets/css/custom.css';
    $var = '';
    if ($wp_filesystem->exists($file)) {
        $scss = $wp_filesystem->get_contents($file);
        if (!$scss) {
            return new WP_Error('reading_error', 'Error when reading file');
        }
        $var .= '$primary-color: ' . $options['primary-color'] . ';';
        $var .= '$secondary-color: ' . $options['secondary-color'] . ';';
        $var .= '$background-color: ' . $options['background-color'] . ';';
        $scss = $var . $scss;
        // Fallback image
        if ($options['nav-bg-fallback-switch'] === '1' && $options['nav-bg-fallback']['url'] !== '') {
            $nav = " .nav-dropline { > li { &.active, &.open, &:hover, &:focus { background: url('" . $options['nav-bg-fallback']['url'] . "') no-repeat bottom left, url('" . $options['nav-bg-fallback']['url'] . "') no-repeat bottom right; @media (min-width: 1200px) { background: url('" . $options['nav-bg-fallback']['url'] . "') no-repeat top left, url('" . $options['nav-bg-fallback']['url'] . "') no-repeat top right; } } } }";
            $scss .= $nav;
        }
        // Fallback Image End;
        $css = $scssc->compile($scss);
        if (!$css) {
            return new WP_Error('compile_error', 'Error on compiling scss to css');
        }
        $wp_filesystem->put_contents($target, $css, FS_CHMOD_FILE);
    }
}
开发者ID:ArgiaCyber,项目名称:alfath,代码行数:38,代码来源:functions.php

示例3: compile_stack

 public function compile_stack($post_id, $css_format)
 {
     // create return value
     $css = '';
     // reset fontstack array
     $this->fontstack = array();
     // setup sass compiler
     if (!class_exists('scssc')) {
         require OXY_THEME_DIR . 'vendor/leafo/scssphp/scss.inc.php';
     }
     $scss = new scssc();
     $scss->addImportPath(OXY_THEME_DIR . 'assets/scss');
     $scss->setNumberPrecision(8);
     $scss->setFormatter($css_format);
     // create sass code
     $scss_code = $this->variables($post_id);
     $scss_code .= apply_filters('oxy_stack_scss', '');
     // compile sass and store in metadata
     try {
         $css = $scss->compile($scss_code);
     } catch (Exception $e) {
         print_r($e);
     }
     // create extra font js / links
     $this->build_before_css_code($post_id);
     return $css;
 }
开发者ID:ntngiri,项目名称:Wordpress-dhaba,代码行数:27,代码来源:OxygennaStacks.php


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