The CSSVariablesRule interface represents a @variables rule within a CSS style sheet. The @variables rule is used to specify variables.
cssutils uses a CSSVariablesDeclaration to represent the variables.
Format:
variables
VARIABLES_SYM S* medium [ COMMA S* medium ]* LBRACE S*
variableset* '}' S*
;
for variableset see cssutils.css.CSSVariablesDeclaration
Media are not implemented. Reason is that cssutils is using CSS variables in a kind of preprocessing and therefor no media information is available at this stage. For now do not use media!
Example:
@variables {
CorporateLogoBGColor: #fe8d12;
}
div.logoContainer {
background-color: var(CorporateLogoBGColor);
}
The CSSVariablesDeclaration interface represents a single block of variable declarations.
Used to retrieve the value of a variable if it has been explicitly set within this variable declaration block.
Parameter: | variableName -- The name of the variable. |
---|---|
Returns: | the value of the variable if it has been explicitly set in this variable declaration block. Returns the empty string if the variable has not been set. |
Used to retrieve the variables that have been explicitly set in this variable declaration block. The order of the variables retrieved using this method does not have to be the order in which they were set. This method can be used to iterate over all variables in this variable declaration block.
Parameter: | index -- of the variable name to retrieve, negative values behave like negative indexes on Python lists, so -1 is the last element |
---|---|
Returns: | The name of the variable at this ordinal position. The empty string if no variable exists at this position. |
Used to remove a variable if it has been explicitly set within this variable declaration block.
Parameter: | variableName -- The name of the variable. |
---|---|
Returns: | the value of the variable if it has been explicitly set for this variable declaration block. Returns the empty string if the variable has not been set. |
Exceptions: |
|
Used to set a variable value within this variable declaration block.
Parameters: |
|
---|---|
Exceptions: |
|