本文整理汇总了PHP中scssc::compile方法的典型用法代码示例。如果您正苦于以下问题:PHP scssc::compile方法的具体用法?PHP scssc::compile怎么用?PHP scssc::compile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scssc
的用法示例。
在下文中一共展示了scssc::compile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
public static function parse($source, $isFile = true)
{
$parser = new scssc();
if ($isFile) {
$parser->setImportPaths(dirname($source));
}
try {
return $isFile ? $parser->compile('@import "' . basename($source) . '"') : $parser->compile($source);
} catch (Exception $e) {
return '/** SASS PARSE ERROR: ' . $e->getMessage() . ' **/';
}
}
示例2: 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));
}
}
}
}
示例3: 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();
}
}
示例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;
}
示例5: 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);
}
}
示例6: 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));
}
}
}
}
示例7: cuttz_scss_compile
function cuttz_scss_compile()
{
if (!current_user_can('update_themes')) {
return;
}
$scss = new scssc();
$scss->setFormatter('scss_formatter');
if (file_exists(CHILD_DIR . '/lib/stylesheet-core/style.scss')) {
if (filemtime(CHILD_DIR . '/lib/stylesheet-core/style.scss') > filemtime(CHILD_DIR . '/style.css')) {
$css = "@charset \"UTF-8\"; \n\n/*S********************************************************************************\n******************** Make all your changes to themes/cuttz/lib/stylesheet-core/style.scss **************************\n**** This file will be overwritten by style.scss and your changes will be lost ****\n**********************************************************************************/\n\n";
$css = '';
$css .= $scss->compile('@import "' . CHILD_DIR . '/lib/stylesheet-core/style.scss' . '"');
file_put_contents(CHILD_DIR . '/style.css', $css);
if (function_exists('w3tc_browsercache_flush')) {
//check if W3Total cache is installed and active
w3tc_browsercache_flush();
//flush the w3tc browser cache to fetch the new css
}
}
}
if (file_exists(cuttz_current_skin_path() . '/style.scss')) {
if (filemtime(cuttz_current_skin_path() . '/style.scss') > @filemtime(cuttz_current_skin_path() . '/autogenerated.css')) {
$css = "@charset \"UTF-8\"; \n\n/*D*********************************************************************************\n******************** Make all your changes to style.scss **************************\n**** This file will be overwritten by style.scss and your changes will be lost ****\n**********************************************************************************/\n\n";
$css .= $scss->compile('@import "' . cuttz_current_skin_path() . '/style.scss' . '"');
file_put_contents(cuttz_current_skin_path() . '/autogenerated.css', $css);
if (function_exists('w3tc_browsercache_flush')) {
//check if W3Total cache is installed and active
w3tc_browsercache_flush();
//flush the w3tc browser cache to fetch the new css
}
}
}
$user_dir = cuttz_get_res('dir');
if (file_exists($user_dir . 'style.scss')) {
if (filemtime($user_dir . 'style.scss') > @filemtime($user_dir . 'autogenerated.css')) {
$css = "@charset \"UTF-8\"; \n\n/*U********************************************************************************\n******************** Make all your changes to style.scss **************************\n**** This file will be overwritten by style.scss and your changes will be lost ****\n**********************************************************************************/\n\n";
$css .= $scss->compile('@import "' . $user_dir . 'style.scss' . '"');
file_put_contents($user_dir . 'autogenerated.css', $css);
if (function_exists('w3tc_browsercache_flush')) {
//check if W3Total cache is installed and active
w3tc_browsercache_flush();
//flush the w3tc browser cache to fetch the new css
}
}
}
}
示例8: init
public function init($css = '')
{
require "compass/vendor/autoload.php";
require "compass/compass.inc.php";
$scss = new scssc();
new scss_compass($scss);
return $scss->compile('@import "compass";' . $css);
}
示例9: 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"'));
}
示例10: __invoke
/**
* @see PreFileFilter::__invoke()
*/
public function __invoke($code, \Lohini\WebLoader\WebLoader $loader, $file = NULL)
{
if ($file === NULL || strtolower(pathinfo($file, PATHINFO_EXTENSION)) != 'scss') {
return $code;
}
$filter = new \scssc($file);
return $filter->compile();
}
示例11: jetpack_sass_css_preprocess
function jetpack_sass_css_preprocess($sass)
{
require_once dirname(__FILE__) . '/preprocessors/scss.inc.php';
$compiler = new scssc();
try {
return $compiler->compile($sass);
} catch (Exception $e) {
return $sass;
}
}
示例12: filterLoad
public function filterLoad(AssetInterface $asset)
{
$root = $asset->getSourceRoot();
$path = $asset->getSourcePath();
$lc = new \scssc();
if ($root && $path) {
$lc->addImportPath(dirname($root . '/' . $path));
}
$asset->setContent($lc->compile($asset->getContent()));
}
示例13: compile
/**
* Compile the SCSS
* @param \Contao\ThemeModel
* @param boolean
*/
public static function compile(\Contao\ThemeModel $objTheme, $blnForce = false)
{
if (!self::confirmDependencies()) {
return;
}
//Get file key
$strKey = self::getKey($objTheme);
//Set file path
$strCSSPath = 'assets/foundation/css/' . $strKey . '.css';
//Compile the scss
if (!file_exists(TL_ROOT . '/' . $strCSSPath) || $blnForce) {
//Gather up the SCSS files in the assets/foundation/scss folder
//This allows to work with different configs and edit defaults
//Without affecting the original source
$strBasePath = COMPOSER_DIR_RELATIVE . '/vendor/zurb/foundation/scss';
$strCopyPath = 'assets/foundation/scss/' . $strKey;
//Create new folder if not exists and clean it out
$objNew = new \Folder($strCopyPath);
$objNew->purge();
$objOriginal = new \Folder($strBasePath);
$objOriginal->copyTo($strCopyPath);
//Apply the config
self::applyConfig($objTheme, $strCopyPath);
$strFoundationCSS = '';
$strNormalizeCSS = '';
//Create the SCSS compiler
$objCompiler = new \scssc();
$objCompiler->setImportPaths(TL_ROOT . '/' . $strCopyPath);
$objCompiler->setFormatter(\Config::get('debugMode') ? 'scss_formatter' : 'scss_formatter_compressed');
$strFoundationContent = file_get_contents(TL_ROOT . '/' . $strCopyPath . '/foundation.scss');
$strNormalizeContent = file_get_contents(TL_ROOT . '/' . $strCopyPath . '/normalize.scss');
//Compile
$strFoundationCSS = $objCompiler->compile($strFoundationContent);
$strNormalizeCSS = $objCompiler->compile($strNormalizeContent);
//Write to single CSS file cache
$objFile = new \File($strCSSPath);
$objFile->write($strNormalizeCSS . "\n" . $strFoundationCSS);
$objFile->close();
}
return $strCSSPath;
}
示例14: input
/**
* Runs `scssc` against any files that match the configured extension.
*
* @param string $filename The name of the input file.
* @param string $input The content of the file.
* @throws Exception
* @return string
*/
public function input($filename, $input)
{
if (substr($filename, strlen($this->_settings['ext']) * -1) !== $this->_settings['ext']) {
return $input;
}
App::import('Vendor', 'scssc', array('file' => $this->_settings['path']));
if (!class_exists('scssc')) {
throw new Exception(sprintf('Cannot not load filter class "%s".', 'scssc'));
}
$sc = new scssc();
$sc->addImportPath(dirname($filename));
return $sc->compile($input);
}
示例15: filterLoad
public function filterLoad(AssetInterface $asset)
{
$lc = new \scssc();
if ($this->compass) {
new \scss_compass($lc);
}
if ($dir = $asset->getSourceDirectory()) {
$lc->addImportPath($dir);
}
foreach ($this->importPaths as $path) {
$lc->addImportPath($path);
}
$asset->setContent($lc->compile($asset->getContent()));
}