public function compileBlock(the
$block,
[the
$parentTags = NULL,
[boolean
$bindEnv = true]] )
Parameters
$block
—
object
block
$parentTags
—
object
tags of the block that contained this one
$bindEnv
—
boolean
if we should bind the block before compiling 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.
A block is stored in a PHP array(). Each entry in the array represents some structure. The key is the name, and the value is the value of the structure. Some structures do not have names, they are prefixed with either __literal or __special in order to be differentiated. Some additional meta-data which is not to be printed is also stored in a block, their names begining with __. (eg. __tags, __args)
Because in less, CSS blocks can be described by nesting, compileBlock must be aware of where it came from. The argument $parentTags stores the selector tags of where the block was defined, null represents no parents.
The __tags meta-data in the block stores the actual selector tags the block has. (We can't just use the key in the array because sometimes a block can have multiple selector tags separated by ,) The parent tags are "multiplied" against the __tags in order to get all the real selectors that describe the block. (This value is also recursively passed to compileBlock when compiling sub blocks).
After that, if the block has any arguments with default values they are inserted as an environment so their values can be accessed when reducing any variables.
The block is then iterated on, compiling each component individually. If another block is found, then it is recursively compiled.