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


PHP Less_Parser::parse方法代码示例

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


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

示例1: cupid_generate_less

/**
 * Created by PhpStorm.
 * User: duonglh
 * Date: 8/23/14
 * Time: 3:01 PM
 */
function cupid_generate_less()
{
    require_once 'Less.php';
    $cupid_data = of_get_options();
    try {
        $primary_color = $cupid_data['primary-color'];
        $secondary_color = $cupid_data['secondary-color'];
        $button_color = $cupid_data['button-color'];
        $bullet_color = $cupid_data['bullet-color'];
        $icon_box_color = $cupid_data['icon-box-color'];
        $site_logo_url = $cupid_data['site-logo'];
        $site_logo_white_url = $cupid_data['site-logo-white'];
        $site_logo_url = str_replace(THEME_URL, '', $site_logo_url);
        $site_logo_white_url = str_replace(THEME_URL, '', $site_logo_white_url);
        $css = '@primary_color:' . $primary_color . ';';
        $css .= '@secondary_color:' . $secondary_color . ';';
        $css .= '@button_color:' . $button_color . ';';
        $css .= '@bullet_color:' . $bullet_color . ';';
        $css .= '@icon_box_color:' . $icon_box_color . ';';
        $css .= "@logo_url : '" . $site_logo_url . "';@logo_white_url : '" . $site_logo_white_url . "';";
        $css .= '@theme_url:"' . THEME_URL . '";';
        $style = $css;
        require_once ABSPATH . 'wp-admin/includes/file.php';
        require_once THEME_DIR . "lib/inc-generate-less/custom-css.php";
        $custom_css = cupid_custom_css();
        WP_Filesystem();
        global $wp_filesystem;
        $options = array('compress' => true);
        $parser = new Less_Parser($options);
        $parser->parse($css);
        $parser->parseFile(THEME_DIR . 'assets/css/less/style.less');
        $parser->parse($custom_css);
        $css = $parser->getCss();
        if (!$wp_filesystem->put_contents(THEME_DIR . "style.min.css", $css, FS_CHMOD_FILE)) {
            echo __('Could not save file', 'cupid');
            return '0';
        }
        /*$theme_info = $wp_filesystem->get_contents( THEME_DIR . "theme-info.txt" );
                $parser = new Less_Parser();
                $parser->parse($style);
                $parser->parseFile(THEME_DIR . 'assets/css/less/style.less',THEME_URL);
                $style = $parser->getCss();
        		$parser->parse($custom_css);
                $style = $theme_info . "\n" . $style;
                $style = str_replace("\r\n","\n", $style);
                $wp_filesystem->put_contents( THEME_DIR.   "style.css", $style, FS_CHMOD_FILE);*/
        return '1';
    } catch (Exception $e) {
        echo 'Caught exception: ', $e->getMessage(), "\n";
        return '0';
    }
}
开发者ID:adwleg,项目名称:site,代码行数:58,代码来源:generate-less.php

示例2: 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

示例3: compile

 public function compile($source, $pathname)
 {
     $less = new \Less_Parser();
     $less->SetImportDirs(array(dirname($pathname) => './'));
     $less->parse($source);
     return $less->getCss();
 }
开发者ID:nagumo,项目名称:Phest,代码行数:7,代码来源:CompilerLess.php

示例4: CssPreprocessor

function CssPreprocessor($content, $type)
{
    if ($type == 'css') {
    } else {
        if ($type == 'less') {
            try {
                $parser = new Less_Parser();
                $parser->parse($content);
                $content = $parser->getCss();
            } catch (Exception $e) {
                var_dump($e->getMessage());
            }
        } else {
            if ($type == 'sass') {
                $scss = new scssc();
                $content = $scss->compile($content);
            } else {
                if ($type == 'stylus') {
                    $stylus = new Stylus();
                    $content = $stylus->fromString($content)->toString();
                }
            }
        }
    }
    return $content;
}
开发者ID:juijs,项目名称:store.jui.io,代码行数:26,代码来源:bootstrap.php

示例5: compileFile

 /**
  * @param string $themeName
  * @param string $lessFile
  * @return string
  */
 public function compileFile($themeName, $lessFile)
 {
     $model = Model::instance();
     $theme = $model->getTheme($themeName);
     $options = $theme->getOptionsAsArray();
     $configModel = ConfigModel::instance();
     $config = $configModel->getAllConfigValues($themeName);
     $less = "@import '{$lessFile}';";
     $less .= $this->generateLessVariables($options, $config);
     $css = '';
     try {
         require_once ipFile('Ip/Lib/less.php/Less.php');
         $themeDir = ipFile('Theme/' . $themeName . '/assets/');
         $ipContentDir = ipFile('Ip/Internal/Core/assets/ipContent/');
         // creating new context to pass theme assets directory dynamically to a static callback function
         $context = $this;
         $callback = function ($parseFile) use($context, $themeDir) {
             return $context->overrideImportDirectory($themeDir, $parseFile);
         };
         $parserOptions = array('import_callback' => $callback, 'cache_dir' => ipFile('file/tmp/less/'), 'relativeUrls' => false, 'sourceMap' => true);
         $parser = new \Less_Parser($parserOptions);
         $directories = array($themeDir => '', $ipContentDir => '');
         $parser->SetImportDirs($directories);
         $parser->parse($less);
         $css = $parser->getCss();
         $css = "/* Edit {$lessFile}, not this file. */" . "\n" . $css;
     } catch (\Exception $e) {
         ipLog()->error('Less compilation error: Theme - ' . $e->getMessage());
     }
     return $css;
 }
开发者ID:Umz,项目名称:ImpressPages,代码行数:36,代码来源:LessCompiler.php

示例6: compile

 public static function compile($source, $path, $todir, $importdirs)
 {
     $parser = new Less_Parser();
     $parser->SetImportDirs($importdirs);
     $parser->parse($source, CANVASLess::relativePath($todir, dirname($path)) . basename($path));
     $output = $parser->getCss();
     return $output;
 }
开发者ID:shamsbd71,项目名称:canvas-framework,代码行数:8,代码来源:less.php

示例7: compile

 public static function compile($source, $importdirs)
 {
     $parser = new Less_Parser();
     $parser->SetImportDirs($importdirs);
     $parser->parse($source);
     $output = $parser->getCss();
     return $output;
 }
开发者ID:grlf,项目名称:eyedock,代码行数:8,代码来源:less.php

示例8: wpless2csssavecss

 public function wpless2csssavecss($creds)
 {
     $plugindir = plugin_dir_path(__FILE__);
     if (!class_exists('Less_Parser')) {
         require $plugindir . 'less-php/Less.php';
     }
     $options = array('compress' => true, 'credits' => $creds);
     $parser = new Less_Parser($options);
     WP_Filesystem($creds);
     global $wp_filesystem;
     if (!$wp_filesystem->exists($rootless = trailingslashit($wp_filesystem->wp_themes_dir()) . trailingslashit(get_stylesheet()) . 'wpless2css/wpless2css.less')) {
         if (!$wp_filesystem->exists($rootless = trailingslashit($wp_filesystem->wp_themes_dir()) . trailingslashit(get_template()) . 'wpless2css/wpless2css.less')) {
             if (!$wp_filesystem->exists($rootless = trailingslashit($wp_filesystem->wp_content_dir()) . 'wpless2css/wpless2css.less')) {
                 wp_die(__('<strong>wpless2css/wpless2css.less</strong> is missing', 'wpless2css'));
             }
         }
     }
     $parser->parseFile($rootless, '../');
     $parser->parse(apply_filters('get_theme_mods', ''));
     if ($extrafiles = apply_filters('add_extra_less_files', '')) {
         foreach ($extrafiles as $extrafile) {
             $parser->parseFile(trailingslashit(str_replace('wp-content/', '', $wp_filesystem->wp_content_dir())) . $extrafile);
         }
     }
     $parser->parse(apply_filters('add_extra_less_code', ''));
     $parser->parse(get_theme_mod('customlesscode'));
     $css = $parser->getCss();
     if (is_rtl()) {
         $css = str_replace('navbar-left', 'navbar-l', $css);
         $css = str_replace('navbar-right', 'navbar-r', $css);
         $css = str_replace('left', 'wasleft', $css);
         $css = str_replace('right', 'left', $css);
         $css = str_replace('wasleft', 'right', $css);
         $css = str_replace('navbar-l', 'navbar-left', $css);
         $css = str_replace('navbar-r', 'navbar-right', $css);
         $css .= ' body{direction: rtl; unicode-bidi: embed;}';
         set_theme_mod('rtl_compiled', 1);
     } else {
         set_theme_mod('rtl_compiled', 0);
     }
     $folder = trailingslashit($wp_filesystem->wp_themes_dir()) . trailingslashit(get_stylesheet()) . '/';
     if (!$wp_filesystem->put_contents($folder . $this->filename, $css, FS_CHMOD_FILE)) {
         wp_die("error saving file!");
     }
     //file_put_contents( $this->folder.$this->filename, $css);
 }
开发者ID:jwlayug,项目名称:jbst,代码行数:46,代码来源:wp-less-to-css.php

示例9: 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();
 }
开发者ID:difra-org,项目名称:difra,代码行数:13,代码来源:Less.php

示例10: alleycat_compiler

function alleycat_compiler()
{
    $minimize_css = shoestrap_getVariable('minimize_css', true);
    $options = $minimize_css == 1 ? array('compress' => true) : array('compress' => false);
    $bootstrap_location = get_template_directory() . '/assets/less/';
    $bootstrap_uri = '';
    try {
        $parser = new Less_Parser($options);
        // AC LESS file
        $parser->parseFile($bootstrap_location . 'alleycat.less', $bootstrap_uri);
        // Our custom variables
        $parser->parse(shoestrap_variables());
        // Add a filter to the compiler
        $parser->parse(apply_filters('shoestrap_compiler', ''));
        $css = $parser->getCss();
    } catch (Exception $e) {
        $error_message = $e->getMessage();
        error_log($error_message);
    }
    // Below is just an ugly hack
    $css = str_replace('bootstrap/fonts/', '', $css);
    $css = str_replace(get_template_directory_uri() . '/assets/', '../', $css);
    return apply_filters('shoestrap_compiler_output', $css);
}
开发者ID:Jhorton4,项目名称:Bohldfeys_Portfolio,代码行数:24,代码来源:functions.compiler.php

示例11: processSubmit

 function processSubmit($mode)
 {
     $data = get_option('Lesser_APF');
     $less = $data['lesser_' . $mode . '_less'];
     $parser = new Less_Parser();
     try {
         $parser->parse($less);
         $css = $parser->getCss();
         $data['lesser_' . $mode . '_css'] = $css;
         $data = apply_filters('lesser_before_' . $mode . '_save', $data);
         update_option('Lesser_APF', $data);
     } catch (Exception $e) {
         $this->setSettingNotice('LESS parse error: ' . $e->getMessage());
     }
 }
开发者ID:benallfree,项目名称:wp-lesser,代码行数:15,代码来源:Lesser_APF.php

示例12: parse_string

 public function parse_string($template, $data = array(), $return = FALSE, $config = array())
 {
     if (!is_array($config)) {
         $config = array();
     }
     $config = array_merge($this->config, $config);
     $ci = $this->ci;
     $is_mx = false;
     if (!$return) {
         list($ci, $is_mx) = $this->detect_mx();
     }
     $parser = new Less_Parser($config);
     $parser->parse($template);
     $template = $parser->getCss();
     return $this->output($template, $return, $ci, $is_mx);
 }
开发者ID:patilstar,项目名称:HMVC-WITH-CI,代码行数:16,代码来源:Parser_less.php

示例13: 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');
         }
     }
 }
开发者ID:just-paja,项目名称:fudjan,代码行数:18,代码来源:style.php

示例14: 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();
 }
开发者ID:rdeutz,项目名称:Robo,代码行数:25,代码来源:Less.php

示例15: bootswatch_css

/**
 * Adds inline CSS in header.
 */
function bootswatch_css()
{
    $css = '';
    /**
     * Fix overlapping with WordPress admin bar.
     */
    $css .= 'body.admin-bar .navbar-fixed-top{ top: 32px; }';
    /**
     * Fix overlapping with Bootstrap's fixed navbar.
     */
    if (bootswatch_use('fixed_navbar')) {
        $variables_path = bootswatch_get_option('theme') ? get_template_directory() . '/vendor/thomaspark/bootswatch/' . bootswatch_get_option('theme') . '/variables.less' : get_template_directory() . '/vendor/thomaspark/bootswatch/bower_components/bootstrap/less/variables.less';
        $less_parser = new Less_Parser();
        $less_parser->parseFile($variables_path, home_url());
        $less_parser->parse('body { padding-top: (@navbar-height + @navbar-margin-bottom); }');
        $css .= $less_parser->getCss();
    }
    printf('<style>%s</style>', $css);
    // WPCS: xss ok.
}
开发者ID:kadimi,项目名称:bootswatch,代码行数:23,代码来源:css.php


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