dolibarr  17.0.4
Public Member Functions | Protected Member Functions | List of all members
Lessc Class Reference

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

Collaboration diagram for Lessc:
Collaboration graph
[legend]

Public Member Functions

 compileValue ($value)
 Compiles a primitive value into a CSS property value. More...
 
 colorArgs ($args)
 Helper function to get arguments for color manipulation functions. More...
 
 __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. More...
 
 throwError ($msg=null)
 Uses the current value of $this->count to show line and line number.
 

Protected Member Functions

 fileExists ($name)
 fileExists More...
 
 compileBlock ($block)
 Recursively compiles a block. More...
 
 deduplicate ($lines)
 Deduplicate lines in a block. More...
 
 lib_data_uri ($value)
 Given an url, decide whether to output a regular link or the base64-encoded contents of the file. More...
 
 lib_tint ($args)
 Mix color with white in variable proportion. More...
 
 lib_shade ($args)
 Mix color with black in variable proportion. More...
 
 toRGB ($color)
 Converts a hsl array into a color value in rgb. More...
 
 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.5.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 38 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 lessphp cache structure

Definition at line 2252 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 1207 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 210 of file lessc.class.php.

◆ 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 886 of file lessc.class.php.

◆ 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 321 of file lessc.class.php.

◆ fileExists()

Lessc::fileExists (   $name)
protected

fileExists

Parameters
string$nameFilename
Returns
boolean

Definition at line 86 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 1083 of file lessc.class.php.

◆ 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 1358 of file lessc.class.php.

◆ 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 1335 of file lessc.class.php.

◆ 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 1573 of file lessc.class.php.


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