dolibarr 20.0.0
Lessc Class Reference

lessphp v0.8.0 http://leafo.net/lessphp More...

Collaboration diagram for Lessc:

Public Member Functions

 compileValue ($value)
 Compiles a primitive value into a CSS property value.
 
 colorArgs ($args)
 Helper function to get arguments for color manipulation functions.
 
 __construct ($fname=null)
 Initialize any static state, can initialize parser for a file $opts isn't used yet.
 
 cachedCompile ($in, $force=false)
 Execute lessphp on a .less file or a lessphp cache structure.
 
 throwError ($msg=null)
 Uses the current value of $this->count to show line and line number.
 

Protected Member Functions

 fileExists ($name)
 fileExists
 
 compileBlock ($block)
 Recursively compiles a block.
 
 deduplicate ($lines)
 Deduplicate lines in a block.
 
 lib_data_uri ($value)
 Given an url, decide whether to output a regular link or the base64-encoded contents of the file.
 
 lib_tint ($args)
 Mix color with white in variable proportion.
 
 lib_shade ($args)
 Mix color with black in variable proportion.
 
 lib_mix ($args)
 lib_mix mixes two colors by weight mix(@color1, @color2, [@weight: 50%]); http://sass-lang.com/docs/yardoc/Sass/Script/Functions.html#mix-instance_method
 
 lib_contrast ($args)
 lib_contrast
 
 toRGB ($color)
 Converts a hsl array into a color value in rgb.
 
 funcToColor ($func)
 Convert the rgb, rgba, hsl color literals of function type as returned by the parser into values of color type.
 

Detailed Description

lessphp v0.8.0 http://leafo.net/lessphp

LESS CSS compiler, adapted from http://lesscss.org

Copyright 2013, Leaf Corcoran leafo.nosp@m.t@gm.nosp@m.ail.c.nosp@m.om Licensed under MIT or GPLv3, see LICENSE 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.

Definition at line 40 of file lessc.class.php.

Member Function Documentation

◆ cachedCompile()

Lessc::cachedCompile ( $in,
$force = false )

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
mixed$inInput
bool$forceForce rebuild?
Returns
array|null lessphp cache structure

Definition at line 2286 of file lessc.class.php.

◆ colorArgs()

Lessc::colorArgs ( $args)

Helper function to get arguments for color manipulation functions.

takes a list that contains a color like thing and a percentage

Definition at line 1221 of file lessc.class.php.

◆ compileBlock()

Lessc::compileBlock ( $block)
protected

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()

Definition at line 221 of file lessc.class.php.

References throwError().

◆ compileValue()

Lessc::compileValue ( $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.

Definition at line 898 of file lessc.class.php.

References compileValue(), and throwError().

Referenced by compileValue().

◆ deduplicate()

Lessc::deduplicate ( $lines)
protected

Deduplicate lines in a block.

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

Definition at line 332 of file lessc.class.php.

◆ fileExists()

Lessc::fileExists ( $name)
protected

fileExists

Parameters
string$nameFilename
Returns
boolean

Definition at line 97 of file lessc.class.php.

◆ lib_contrast()

Lessc::lib_contrast ( $args)
protected

lib_contrast

Parameters
array$argsArgs
Returns
array

Definition at line 1440 of file lessc.class.php.

◆ lib_data_uri()

Lessc::lib_data_uri ( $value)
protected

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

Parameters
array$valueeither an argument list (two strings) or a single string
Returns
string formatted url(), either as a link or base64-encoded

Definition at line 1096 of file lessc.class.php.

◆ lib_mix()

Lessc::lib_mix ( $args)
protected

lib_mix mixes two colors by weight mix(@color1, @color2, [@weight: 50%]); http://sass-lang.com/docs/yardoc/Sass/Script/Functions.html#mix-instance_method

Parameters
array$argsArgs
Returns
array

Definition at line 1396 of file lessc.class.php.

References throwError().

Referenced by lib_shade(), and lib_tint().

◆ lib_shade()

Lessc::lib_shade ( $args)
protected

Mix color with black in variable proportion.

It is the same as calling mix(#000000, @color, @weight)

shade(@color, [@weight: 50%]);

http://lesscss.org/functions/#color-operations-shade

Returns
array Color

Definition at line 1374 of file lessc.class.php.

References lib_mix(), and throwError().

◆ lib_tint()

Lessc::lib_tint ( $args)
protected

Mix color with white in variable proportion.

It is the same as calling mix(#ffffff, @color, @weight).

tint(@color, [@weight: 50%]);

http://lesscss.org/functions/#color-operations-tint

Returns
array Color

Definition at line 1350 of file lessc.class.php.

References lib_mix(), and throwError().

◆ toRGB()

Lessc::toRGB ( $color)
protected

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

Definition at line 1602 of file lessc.class.php.

Referenced by funcToColor().


The documentation for this class was generated from the following file: