clearFusionCMS 3.0.0
  • Package
  • Class
  • Tree
  • Deprecated

Packages

  • clearFusionCMS
    • module
      • cloudflare
      • comments
      • content
      • forms
      • members
      • search
  • fusionLib
  • None

Classes

  • lessc
  • lessc_formatter_classic
  • lessc_formatter_compressed
  • lessc_formatter_lessjs
  • lessc_parser

Class lessc

The LESS compiler and parser.

Converting LESS to CSS is a three stage process. The incoming file is parsed by lessc_parser into a syntax tree, then it is compiled into another tree representing the CSS structure by lessc. The CSS tree is fed into a formatter, like lessc_formatter which then outputs CSS as a string.

During the first compile, all values are reduced, which means that their types are brought to the lowest form before being dump as strings. This handles math equations, variable dereferences, and the like.

The parse function of lessc is the entry point.

In summary:

The lessc class creates an instance of the parser, feeds it LESS code, then transforms the resulting tree to a CSS tree. This class also holds the evaluation context, such as all available mixins and variables at any given time.

The lessc_parser class is only concerned with parsing its input.

The lessc_formatter takes a CSS tree, and dumps it to a formatted string, handling things like indentation.

Located at system/app/lessphp/lessc.inc.php

Methods summary

protected
# findImport( $url )
protected
# fileExists( $name )
public static
# compressList( $items, $delim )
public static
# preg_quote( $what )
protected
# tryImport( $importPath, $parentBlock, $out )
protected
# compileImportedProps( $props, $block, $out, $sourceParser, $importDir )
protected
# compileBlock( $block )

Recursively compiles a block.

Recursively compiles a block.

A block is analogous to a CSS block in most cases. A single LESS document is encapsulated in a block when parsed, but it does not have parent tags so all of it's children appear on the root level when compiled.

Blocks are made up of props and children.

Props are property instructions, array tuples which describe an action to be taken, eg. write a property, set a variable, mixin a block.

The children of a block are just all the blocks that are defined within. This is used to look up mixins when performing a mixin.

Compiling the block involves pushing a fresh environment on the stack, and iterating through the props, compiling each one.

See lessc::compileProp()

protected
# compileCSSBlock( $block )
protected
# compileMedia( $media )
protected
# mediaParent( $scope )
protected
# compileNestedBlock( $block, $selectors )
protected
# compileRoot( $root )
protected
# compileProps( $block, $out )
protected
# deduplicate( $lines )

Deduplicate lines in a block. Comments are not deduplicated. If a duplicate rule is detected, the comments immediately preceding each occurence are consolidated.

Deduplicate lines in a block. Comments are not deduplicated. If a duplicate rule is detected, the comments immediately preceding each occurence are consolidated.

protected
# sortProps( $props, $split = false )
protected
# compileMediaQuery( $queries )
protected
# multiplyMedia( $env, $childQueries = null )
protected
# expandParentSelectors( & $tag, $replace )
protected
# findClosestSelectors( )
protected
# multiplySelectors( $selectors )
protected
# compileSelectors( $selectors )
protected
# eq( $left, $right )
protected
# patternMatch( $block, $orderedArgs, $keywordArgs )
protected
# patternMatchAll( $blocks, $orderedArgs, $keywordArgs, $skip = array() )
protected
# findBlocks( $searchIn, $path, $orderedArgs, $keywordArgs, $seen = array() )
protected
# zipSetArgs( $args, $orderedValues, $keywordValues )
protected
# compileProp( $prop, $block, $out )
public
# compileValue( $value )

Compiles a primitive value into a CSS property value.

Compiles a primitive value into a CSS property value.

Values in lessphp are typed by being wrapped in arrays, their format is typically: array(type, contents [, additional_contents]*)

The input is expected to be reduced. This function will not work on things like expressions and variables.

protected
# lib_pow( $args )
protected
# lib_pi( )
protected
# lib_mod( $args )
protected
# lib_tan( $num )
protected
# lib_sin( $num )
protected
# lib_cos( $num )
protected
# lib_atan( $num )
protected
# lib_asin( $num )
protected
# lib_acos( $num )
protected
# lib_sqrt( $num )
protected
# lib_extract( $value )
protected
# lib_isnumber( $value )
protected
# lib_isstring( $value )
protected
# lib_iscolor( $value )
protected
# lib_iskeyword( $value )
protected
# lib_ispixel( $value )
protected
# lib_ispercentage( $value )
protected
# lib_isem( $value )
protected
# lib_isrem( $value )
protected
# lib_rgbahex( $color )
protected
# lib_argb( $color )
protected string
# lib_data_uri( array $value )

Given an url, decide whether to output a regular link or the base64-encoded contents of the file

Given an url, decide whether to output a regular link or the base64-encoded contents of the file

Parameters

$value
either an argument list (two strings) or a single string

Returns

string
formatted url(), either as a link or base64-encoded
protected
# lib_e( $arg )
protected
# lib__sprintf( $args )
protected
# lib_floor( $arg )
protected
# lib_ceil( $arg )
protected
# lib_round( $arg )
protected
# lib_unit( $arg )
public
# colorArgs( $args )

Helper function to get arguments for color manipulation functions. takes a list that contains a color like thing and a percentage

Helper function to get arguments for color manipulation functions. takes a list that contains a color like thing and a percentage

protected
# lib_darken( $args )
protected
# lib_lighten( $args )
protected
# lib_saturate( $args )
protected
# lib_desaturate( $args )
protected
# lib_spin( $args )
protected
# lib_fadeout( $args )
protected
# lib_fadein( $args )
protected
# lib_hue( $color )
protected
# lib_saturation( $color )
protected
# lib_lightness( $color )
protected
# lib_alpha( $value )
protected
# lib_fade( $args )
protected
# lib_percentage( $arg )
protected
# lib_mix( $args )
protected
# lib_contrast( $args )
protected
# lib_luma( $color )
public
# assertColor( $value, $error = "expected color value" )
public
# assertNumber( $value, $error = "expecting number" )
public
# assertArgs( $value, $expectedArgs, $name = "" )
protected
# toHSL( $color )
protected
# toRGB_helper( $comp, $temp1, $temp2 )
protected
# toRGB( $color )

Converts a hsl array into a color value in rgb. Expects H to be in range of 0 to 360, S and L in 0 to 100

Converts a hsl array into a color value in rgb. Expects H to be in range of 0 to 360, S and L in 0 to 100

protected
# clamp( $v, $max = 1, $min = 0 )
protected
# funcToColor( $func )

Convert the rgb, rgba, hsl color literals of function type as returned by the parser into values of color type.

Convert the rgb, rgba, hsl color literals of function type as returned by the parser into values of color type.

protected
# reduce( $value, $forExpression = false )
protected
# coerceColor( $value )
protected
# coerceString( $value )
protected
# flattenList( $value )
public
# toBool( $a )
protected
# evaluate( $exp )
protected
# stringConcatenate( $left, $right )
protected
# fixColor( $c )
protected
# op_number_color( $op, $lft, $rgt )
protected
# op_color_number( $op, $lft, $rgt )
protected
# op_color_color( $op, $left, $right )
public
# lib_red( $color )
public
# lib_green( $color )
public
# lib_blue( $color )
protected
# op_number_number( $op, $left, $right )
protected
# makeOutputBlock( $type, $selectors = null )
protected
# pushEnv( $block = null )
protected
# popEnv( )
protected
# set( $name, $value )
protected
# get( $name )
protected
# injectVariables( $args )
public
# __construct( $fname = null )

Initialize any static state, can initialize parser for a file $opts isn't used yet

Initialize any static state, can initialize parser for a file $opts isn't used yet

public
# compile( $string, $name = null )
public
# compileFile( $fname, $outFname = null )
public
# checkedCompile( $in, $out )
public array
# cachedCompile( mixed $in, boolean $force = false )

Execute lessphp on a .less file or a lessphp cache structure

Execute lessphp on a .less file or a lessphp cache structure

The lessphp cache structure contains information about a specific less file having been parsed. It can be used as a hint for future calls to determine whether or not a rebuild is required.

The cache structure contains two important keys that may be used externally:

compiled: The final compiled CSS updated: The time (in seconds) the CSS was last compiled

The cache structure is a plain-ol' PHP associative array and can be serialized and unserialized without a hitch.

Parameters

$in
Input
$force
Force rebuild?

Returns

array
lessphp cache structure
public
# parse( $str = null, $initialVariables = null )
protected
# makeParser( $name )
public
# setFormatter( $name )
protected
# newFormatter( )
public
# setPreserveComments( $preserve )
public
# registerFunction( $name, $func )
public
# unregisterFunction( $name )
public
# setVariables( $variables )
public
# unsetVariable( $name )
public
# setImportDir( $dirs )
public
# addImportDir( $dir )
public
# allParsedFiles( )
public
# addParsedFile( $file )
public
# throwError( $msg = null )

Uses the current value of $this->count to show line and line number

Uses the current value of $this->count to show line and line number

public static
# ccompile( $in, $out, $less = null )
public static
# cexecute( $in, $force = false, $less = null )

Properties summary

public static string $VERSION
# "v0.4.0"
public static array $TRUE
# array("keyword", "true")
public static array $FALSE
# array("keyword", "false")
protected array $libFunctions
# array()
protected array $registeredVars
# array()
protected boolean $preserveComments
# false
public string $vPrefix
# '@'
public string $mPrefix
# '$'
public string $parentSelector
# '&'
public boolean $importDisabled
# false
public string $importDir
# ''
protected $numberPrecision
# null
protected array $allParsedFiles
# array()
protected $sourceParser
# null
protected $sourceLoc
# null
protected static integer $nextImportId
# 0
protected static array $cssColors
# array( 'aliceblue' => '240,248,255', 'antiquewhite' => '250,235,215', 'aqua' => '0,255,255', 'aquamarine' => '127,255,212', 'azure' => '240,255,255', 'beige' => '245,245,220', 'bisque' => '255,228,196', 'black' => '0,0,0', 'blanchedalmond' => '255,235,205', 'blue' => '0,0,255', 'blueviolet' => '138,43,226', 'brown' => '165,42,42', 'burlywood' => '222,184,135', 'cadetblue' => '95,158,160', 'chartreuse' => '127,255,0', 'chocolate' => '210,105,30', 'coral' => '255,127,80', 'cornflowerblue' => '100,149,237', 'cornsilk' => '255,248,220', 'crimson' => '220,20,60', 'cyan' => '0,255,255', 'darkblue' => '0,0,139', 'darkcyan' => '0,139,139', 'darkgoldenrod' => '184,134,11', 'darkgray' => '169,169,169', 'darkgreen' => '0,100,0', 'darkgrey' => '169,169,169', 'darkkhaki' => '189,183,107', 'darkmagenta' => '139,0,139', 'darkolivegreen' => '85,107,47', 'darkorange' => '255,140,0', 'darkorchid' => '153,50,204', 'darkred' => '139,0,0', 'darksalmon' => '233,150,122', 'darkseagreen' => '143,188,143', 'darkslateblue' => '72,61,139', 'darkslategray' => '47,79,79', 'darkslategrey' => '47,79,79', 'darkturquoise' => '0,206,209', 'darkviolet' => '148,0,211', 'deeppink' => '255,20,147', 'deepskyblue' => '0,191,255', 'dimgray' => '105,105,105', 'dimgrey' => '105,105,105', 'dodgerblue' => '30,144,255', 'firebrick' => '178,34,34', 'floralwhite' => '255,250,240', 'forestgreen' => '34,139,34', 'fuchsia' => '255,0,255', 'gainsboro' => '220,220,220', 'ghostwhite' => '248,248,255', 'gold' => '255,215,0', 'goldenrod' => '218,165,32', 'gray' => '128,128,128', 'green' => '0,128,0', 'greenyellow' => '173,255,47', 'grey' => '128,128,128', 'honeydew' => '240,255,240', 'hotpink' => '255,105,180', 'indianred' => '205,92,92', 'indigo' => '75,0,130', 'ivory' => '255,255,240', 'khaki' => '240,230,140', 'lavender' => '230,230,250', 'lavenderblush' => '255,240,245', 'lawngreen' => '124,252,0', 'lemonchiffon' => '255,250,205', 'lightblue' => '173,216,230', 'lightcoral' => '240,128,128', 'lightcyan' => '224,255,255', 'lightgoldenrodyellow' => '250,250,210', 'lightgray' => '211,211,211', 'lightgreen' => '144,238,144', 'lightgrey' => '211,211,211', 'lightpink' => '255,182,193', 'lightsalmon' => '255,160,122', 'lightseagreen' => '32,178,170', 'lightskyblue' => '135,206,250', 'lightslategray' => '119,136,153', 'lightslategrey' => '119,136,153', 'lightsteelblue' => '176,196,222', 'lightyellow' => '255,255,224', 'lime' => '0,255,0', 'limegreen' => '50,205,50', 'linen' => '250,240,230', 'magenta' => '255,0,255', 'maroon' => '128,0,0', 'mediumaquamarine' => '102,205,170', 'mediumblue' => '0,0,205', 'mediumorchid' => '186,85,211', 'mediumpurple' => '147,112,219', 'mediumseagreen' => '60,179,113', 'mediumslateblue' => '123,104,238', 'mediumspringgreen' => '0,250,154', 'mediumturquoise' => '72,209,204', 'mediumvioletred' => '199,21,133', 'midnightblue' => '25,25,112', 'mintcream' => '245,255,250', 'mistyrose' => '255,228,225', 'moccasin' => '255,228,181', 'navajowhite' => '255,222,173', 'navy' => '0,0,128', 'oldlace' => '253,245,230', 'olive' => '128,128,0', 'olivedrab' => '107,142,35', 'orange' => '255,165,0', 'orangered' => '255,69,0', 'orchid' => '218,112,214', 'palegoldenrod' => '238,232,170', 'palegreen' => '152,251,152', 'paleturquoise' => '175,238,238', 'palevioletred' => '219,112,147', 'papayawhip' => '255,239,213', 'peachpuff' => '255,218,185', 'peru' => '205,133,63', 'pink' => '255,192,203', 'plum' => '221,160,221', 'powderblue' => '176,224,230', 'purple' => '128,0,128', 'red' => '255,0,0', 'rosybrown' => '188,143,143', 'royalblue' => '65,105,225', 'saddlebrown' => '139,69,19', 'salmon' => '250,128,114', 'sandybrown' => '244,164,96', 'seagreen' => '46,139,87', 'seashell' => '255,245,238', 'sienna' => '160,82,45', 'silver' => '192,192,192', 'skyblue' => '135,206,235', 'slateblue' => '106,90,205', 'slategray' => '112,128,144', 'slategrey' => '112,128,144', 'snow' => '255,250,250', 'springgreen' => '0,255,127', 'steelblue' => '70,130,180', 'tan' => '210,180,140', 'teal' => '0,128,128', 'thistle' => '216,191,216', 'tomato' => '255,99,71', 'transparent' => '0,0,0,0', 'turquoise' => '64,224,208', 'violet' => '238,130,238', 'wheat' => '245,222,179', 'white' => '255,255,255', 'whitesmoke' => '245,245,245', 'yellow' => '255,255,0', 'yellowgreen' => '154,205,50' )
clearFusionCMS 3.0.0 API documentation generated by ApiGen