本文整理汇总了PHP中scssc::setFormatter方法的典型用法代码示例。如果您正苦于以下问题:PHP scssc::setFormatter方法的具体用法?PHP scssc::setFormatter怎么用?PHP scssc::setFormatter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scssc
的用法示例。
在下文中一共展示了scssc::setFormatter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_compiler
/**
* @return scssc
*/
private function get_compiler()
{
if (is_null($this->compiler)) {
if (!class_exists('scssc')) {
require_once dirname(__FILE__) . '/Compiler/lib/scssphp/scss.inc.php';
}
$this->compiler = new scssc();
$this->compiler->setImportPaths($this->get_import_paths());
$this->compiler->setFormatter('scss_formatter_compressed');
}
return $this->compiler;
}
示例2: compile_sass
public static function compile_sass($parent)
{
if (!empty(self::$path)) {
require "scssphp/scss.inc.php";
$scss = new scssc();
$scss->setImportPaths(self::$path);
if (!$parent->args['dev_mode']) {
$scss->setFormatter("scss_formatter_compressed");
}
$new_css = '';
foreach (self::$import as $import) {
$new_css .= $scss->compile($import);
}
if ($new_css != '') {
if ($parent->args['sass']['page_output']) {
echo '<style type="text/css" id="redux-' . $parent->args['opt_name'] . '">' . $new_css . '</style>';
} else {
//Redux_Functions::initWpFilesystem();
//global $wp_filesystem;
$filesystem = $parent->filesystem;
$css_file = Redux_Helpers::cleanFilePath(ReduxFramework::$_upload_dir . $parent->args['opt_name'] . '-redux.css');
//$ret_val = $wp_filesystem->put_contents($css_file, $new_css, FS_CHMOD_FILE);
$ret_val = $filesystem->execute('put_contents', $css_file, array('content' => $new_css));
}
}
}
}
示例3: run
/**
* Compiles all .scss files in a given folder into .css files in a given folder
*
* @param string $scss_folder source folder where you have your .scss files
* @param string $css_folder destination folder where you want your .css files
* @param string $format_style CSS output format, see http://leafo.net/scssphp/docs/#output_formatting for more.
*/
public static function run($scss_folder, $css_folder, $format_style = "scss_formatter")
{
// scssc will be loaded automatically via Composer
$scss_compiler = new scssc();
// set the path where your _mixins are
$scss_compiler->setImportPaths($scss_folder);
// set css formatting (normal, nested or minimized), @see http://leafo.net/scssphp/docs/#output_formatting
$scss_compiler->setFormatter($format_style);
// get all .scss files from scss folder
$filelist = glob($scss_folder . "*.scss");
// step through all .scss files in that folder
foreach ($filelist as $file_path) {
// get path elements from that file
$file_path_elements = pathinfo($file_path);
// get file's name without extension
$file_name = $file_path_elements['filename'];
// get .scss's content, put it into $string_sass
$string_sass = file_get_contents($scss_folder . $file_name . ".scss");
// compile this SASS code to CSS
$string_css = $scss_compiler->compile($string_sass);
// create target directory if doesn't exist
if (!is_dir($css_folder)) {
mkdir($css_folder, 0777, true);
}
// write CSS into file with the same filename, but .css extension
file_put_contents($css_folder . $file_name . ".css", $string_css);
}
}
示例4: run
/**
* Compiles all .scss files in a given folder into .css files in a given folder
*
* @param string $scss_folder source folder where you have your .scss files
* @param string $css_folder destination folder where you want your .css files
* @param string $format_style CSS output format, see http://leafo.net/scssphp/docs/#output_formatting for more.
*/
public static function run($scss_folder, $css_folder, $format_style = "scss_formatter", $file_append = false)
{
// scssc will be loaded automatically via Composer
$scss_compiler = new scssc();
// set the path where your _mixins are
$scss_compiler->setImportPaths($scss_folder);
// set css formatting (normal, nested or minimized), @see http://leafo.net/scssphp/docs/#output_formatting
$scss_compiler->setFormatter($format_style);
// create master css file
if (!is_dir($css_folder) && $file_append == false) {
file_put_contents($css_folder, "");
}
if (is_dir($scss_folder)) {
$scan = scandir($scss_folder);
} else {
$scan = [$scss_folder];
}
if (!file_exists($scss_folder)) {
throw new Exception("Arquivo inexistente: {$scss_folder}");
}
foreach ($scan as $file) {
if (in_array($file, array(".", ".."))) {
continue;
}
if (is_dir($scss_folder)) {
if (!file_exists($css_folder . $file)) {
if (is_dir($css_folder)) {
if (!mkdir($css_folder . $file . "/")) {
throw new Exception("Falha ao compilar arquivo .scss. Não foi possível criar a pasta {$css_folder}{$file}/");
}
if (!chmod($css_folder . $file, 0755)) {
throw new Exception("Falha ao compilar arquivo .scss. Não foi possível mudar a permissão do arquivo {$css_folder}{$file}/ para 755 (rwxr-xr-x)");
}
}
}
if (is_dir($css_folder)) {
self::run($scss_folder . $file . "/", $css_folder . $file . "/", $format_style);
} else {
self::run($scss_folder . $file, $css_folder, $format_style);
}
} else {
if (preg_match('/(.*).scss$/', $file) and $file[0] != '.') {
// get path elements from that file
$file_path_elements = pathinfo($file);
// get file's name without extension
$file_name = $file_path_elements['filename'];
// get .scss's content, put it into $string_sass
$string_sass = file_get_contents($scss_folder);
// compile this SASS code to CSS
$string_css = $scss_compiler->compile($string_sass);
// write CSS into file with the same filename, but .css extension
if (is_dir($css_folder)) {
file_put_contents($css_folder . $file_name . ".css", $string_css);
} else {
file_put_contents($css_folder, $string_css, FILE_APPEND);
}
}
}
}
}
示例5: compile_sass
public static function compile_sass($parent)
{
if (!empty(self::$path)) {
if (!class_exists('scssc') && !isset($GLOBALS['redux_scss_compiler'])) {
$GLOBALS['redux_scss_compiler'] = true;
require "scssphp/scss.inc.php";
}
$scss = new scssc();
$scss->setImportPaths(self::$path);
if (!$parent->args['dev_mode']) {
$scss->setFormatter("scss_formatter_compressed");
}
$new_css = '';
foreach (self::$import as $import) {
$new_css .= $scss->compile($import);
}
if ($new_css != '') {
if ($parent->args['sass']['page_output']) {
echo '<style type="text/css" id="redux-' . $parent->args['opt_name'] . '">' . $new_css . '</style>';
} else {
$filesystem = $parent->filesystem;
$css_file = Redux_Helpers::cleanFilePath(ReduxFramework::$_upload_dir . $parent->args['opt_name'] . '-redux.css');
$ret_val = $filesystem->execute('put_contents', $css_file, array('content' => $new_css));
}
}
}
}
示例6: mob_admin_compile_scss
/**
* Compile SCSS
*
* @return string
*/
function mob_admin_compile_scss($scss_folder, $css_folder, $format_style = "scss_formatter")
{
// scssc will be loaded automatically via Composer
$scss_compiler = new scssc();
// set the path where your _mixins are
$scss_compiler->setImportPaths($scss_folder);
// set css formatting (normal, nested or minimized), @see http://leafo.net/scssphp/docs/#output_formatting
$scss_compiler->setFormatter($format_style);
// get all .scss files from scss folder
$filelist = glob($scss_folder . "*.scss");
try {
// step through all .scss files in that folder
foreach ($filelist as $file_path) {
// get path elements from that file
$file_path_elements = pathinfo($file_path);
// get file's name without extension
$file_name = $file_path_elements['filename'];
// get .scss's content, put it into $string_sass
$string_sass = mob_file_read($scss_folder . $file_name . ".scss");
// compile this SASS code to CSS
$string_css = $scss_compiler->compile($string_sass);
// write CSS into file with the same filename, but .css extension
mob_file_write($css_folder . $file_name . ".css", $string_css);
}
} catch (Exception $e) {
return $e->getMessage();
}
}
示例7: serveStyle
/** Default RudraX Plug
*
* @RequestMapping(url="scss/{mdfile}",type=css)
*
*/
function serveStyle($mdfile)
{
include_once LIB_PATH . "/leafo/scssphp/scss.inc.php";
$scss = new scssc();
$scss->setFormatter("scss_formatter_compressed");
$server = new scss_server(get_include_path(), get_include_path() . BUILD_PATH . "/scss/", $scss);
$server->serve();
}
示例8: compileScss
function compileScss()
{
require "scss.inc.php";
$scss = new scssc();
$scss->setImportPaths(get_stylesheet_directory() . '/assets/scss/');
$scss->setFormatter('scss_formatter_compressed');
file_put_contents(get_stylesheet_directory() . '/assets/css/global-gen.css', $scss->compile('@import "global.scss"'));
}
示例9: __construct
/**
* Set values for Wp_Scss::properties
*
* @param string scss_dir - path to source directory for scss files
* @param string css_dir - path to output directory for css files
* @param string method - type of compile (compressed, expanded, etc)
*
* @var object scssc - instantiate the compiling object.
*
* @var array compile_errors - catches errors from compile
*/
public function __construct($scss_dir, $css_dir, $compile_method)
{
$this->scss_dir = $scss_dir;
$this->css_dir = $css_dir;
$this->compile_method = $compile_method;
global $scssc;
$scssc = new scssc();
$scssc->setFormatter($compile_method);
$scssc->setImportPaths($scss_dir);
$this->compile_errors = array();
}
示例10: jetpack_sass_css_preprocess
function jetpack_sass_css_preprocess($sass)
{
require_once dirname(__FILE__) . '/preprocessors/scss.inc.php';
$compiler = new scssc();
$compiler->setFormatter('scss_formatter');
try {
return $compiler->compile($sass);
} catch (Exception $e) {
return $sass;
}
}
示例11: serve
/**
* Process scss file
*
* @param string $filename
* @return array
*/
public static function serve($filename)
{
$result = ['success' => false, 'error' => [], 'data' => ''];
// try to get scss file
$scss_string = file_get_contents($filename);
if ($scss_string === false) {
$result['error'][] = 'Scss file does not exists!';
} else {
$scss_compiler = new scssc();
$scss_compiler->setFormatter('scss_formatter');
$result['data'] = $scss_compiler->compile($scss_string);
$result['success'] = true;
}
return $result;
}
示例12: compile_scss
/**
* Compile the SCSS.
*
* @return string
*/
protected function compile_scss()
{
if (!class_exists('scssc') && !class_exists('scss_formatter_nested')) {
include_once 'libs/class-scss.php';
}
// Get options
$colors = WC_Colors::get_options(get_option('woocommerce_colors'));
ob_start();
include 'views/scss.php';
$scss = ob_get_clean();
$compiler = new scssc();
$compiler->setFormatter('scss_formatter_compressed');
$compiled_css = $compiler->compile(trim($scss));
return $compiled_css;
}
示例13: run_compiler
public function run_compiler($scss_dir, $sass_vars, $sass_import_file, $css_name, $compile_method = 'scss_formatter_nested')
{
require_once WPCSC_PLUGIN_DIR . '/scssphp/scss.inc.php';
$scss = new scssc();
$scss->setImportPaths($scss_dir);
$scss->setFormatter($compile_method);
$scss->setVariables($sass_vars);
$new_css = $scss->compile($sass_import_file);
/* Write the CSS to the Database */
$wpcscOptions = get_option('wpcsc1208_option_settings');
/* Sanitze the CSS before going into the Database
Refer to this doc, http://wptavern.com/wordpress-theme-review-team-sets-new-guidelines-for-custom-css-boxes */
$wpcscOptions['wpcsc_content'][$css_name] = wp_kses($new_css, array('\'', '\\"'));
update_option('wpcsc1208_option_settings', $wpcscOptions);
}
示例14: compile
public function compile($scss_folder, $scss_filename, $stylename, $format_style = "scss_formatter")
{
require_once plugin_dir_path(__FILE__) . 'lib/scssphp/scss.inc.php';
$scss_compiler = new scssc();
$scss_compiler->setImportPaths($scss_folder);
$scss_compiler->setFormatter($format_style);
try {
$file = $scss_filename;
$content = file_get_contents($file);
$string_css = $scss_compiler->compile($content);
file_put_contents($stylename, $string_css);
} catch (Exception $e) {
echo $e->getMessage();
}
}
示例15: 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;
}
}