PHP Class SassParser

Parses {@link http://sass-lang.com/ Sass} files.
Mostrar archivo Open project: richthegeek/phpsass Class Usage Examples

Public Properties

Property Type Description
$basepath Option
$callbacks callbacks:
$debug Defaults to FALSE
$debug_info debug_info:
$filename filename:
$functions function:
$indentChar the character used for indenting
$indentChars allowable characters for indenting
$indentSpaces number of spaces for indentation. Used to calculate {@link Level} if {@link indentChar} is space.
$instance Static holder for last instance of a SassParser
$line line:
$line_numbers line_numbers:
$load_path_functions
$load_paths load_paths:
$property_syntax property_syntax:
$quiet quiet:
$source source
$style style:
$syntax syntax:

Public Methods

Method Description
__construct ( array $options = [] ) : SassParser Constructor.
__get ( string $name ) : mixed Getter.
buildTree ( SassNode $parent ) : SassNode Builds a parse tree under the parent node.
createToken ( string $statement ) : object | null Returns an object that contains the source statement and meta data about it.
getBasepath ( )
getCallbacks ( )
getDebug ( )
getDebug_info ( )
getFilename ( )
getFunctions ( )
getLevel ( string $source ) : integer Returns the level of the line.
getLine ( )
getLine_numbers ( )
getLoad_path_functions ( )
getLoad_paths ( )
getNode ( SassNode $node ) : SassNode | null Creates and returns the next SassNode.
getOptions ( )
getProperty_syntax ( )
getQuiet ( )
getSource ( )
getStyle ( )
getSyntax ( )
getToken ( ) : object Returns a token object that contains the next source statement and meta data about it.
parse ( string $source, boolean $isFile = true ) : SassRootNode Parse a sass file or Sass source code and returns the document tree that can then be rendered.
parseDirective ( stdClass $token, SassNode $parent ) : SassNode Parses a directive
sass2Token ( ) : object Returns an object that contains the next source statement and meta data about it from SASS source.
scss2Token ( ) : object Returns an object that contains the next source statement and meta data about it from SCSS source.
setIndentChar ( ) Determine the indent character and indent spaces.
toCss ( string $source, boolean $isFile = true ) : string Parse a sass file or Sass source code and returns the CSS.
toTree ( string $source ) : SassRootNode Parse Sass source into a document tree.

Method Details

__construct() public method

Sets parser options
public __construct ( array $options = [] ) : SassParser
$options array
return SassParser

__get() public method

Getter.
public __get ( string $name ) : mixed
$name string name of property to get
return mixed return value of getter function

buildTree() public method

Called recursivly until the source is parsed.
public buildTree ( SassNode $parent ) : SassNode
$parent SassNode the node
return SassNode

createToken() public method

If the statement is just and end block we update the meta data and return null.
public createToken ( string $statement ) : object | null
$statement string source statement
return object | null

getBasepath() public method

public getBasepath ( )

getCallbacks() public method

public getCallbacks ( )

getDebug() public method

public getDebug ( )

getDebug_info() public method

public getDebug_info ( )

getFilename() public method

public getFilename ( )

getFunctions() public method

public getFunctions ( )

getLevel() public method

Used for .sass source
public getLevel ( string $source ) : integer
$source string the source
return integer the level of the source

getLine() public method

public getLine ( )

getLine_numbers() public method

public getLine_numbers ( )

getLoad_path_functions() public method

getLoad_paths() public method

public getLoad_paths ( )

getNode() public method

The tpye of SassNode depends on the content of the SassToken.
public getNode ( SassNode $node ) : SassNode | null
$node SassNode
return SassNode | null a SassNode of the appropriate type. Null when no more source to parse.

getOptions() public method

public getOptions ( )

getProperty_syntax() public method

public getProperty_syntax ( )

getQuiet() public method

public getQuiet ( )

getSource() public method

public getSource ( )

getStyle() public method

public getStyle ( )

getSyntax() public method

public getSyntax ( )

getToken() public method

Returns a token object that contains the next source statement and meta data about it.
public getToken ( ) : object
return object

parse() public method

The file will be searched for in the directories specified by the load_paths option.
public parse ( string $source, boolean $isFile = true ) : SassRootNode
$source string name of source file or Sass source
$isFile boolean
return SassRootNode Root node of document tree

parseDirective() public method

Parses a directive
public parseDirective ( stdClass $token, SassNode $parent ) : SassNode
$token stdClass token to parse
$parent SassNode parent node
return SassNode a Sass directive node

sass2Token() public method

Sass statements are passed over. Statements spanning multiple lines, e.g. CSS comments and selectors, are assembled into a single statement.
public sass2Token ( ) : object
return object Statement token. Null if end of source.

scss2Token() public method

Returns an object that contains the next source statement and meta data about it from SCSS source.
public scss2Token ( ) : object
return object Statement token. Null if end of source.

setIndentChar() public method

The first character of the first indented line determines the character. If this is a space the number of spaces determines the indentSpaces; this is always 1 if the indent character is a tab. Only used for .sass files.
public setIndentChar ( )

toCss() public method

Parse a sass file or Sass source code and returns the CSS.
public toCss ( string $source, boolean $isFile = true ) : string
$source string name of source file or Sass source
$isFile boolean
return string CSS

toTree() public method

If the tree is already created return that.
public toTree ( string $source ) : SassRootNode
$source string Sass source
return SassRootNode the root of this document tree

Property Details

$basepath public_oe property

Option
public $basepath

$callbacks public_oe property

callbacks:
public $callbacks

$debug public_oe property

Defaults to FALSE
public $debug

$debug_info public_oe property

debug_info:
See also: style
public $debug_info

$filename public_oe property

filename:
public $filename

$functions public_oe static_oe property

function:
public static $functions

$indentChar public_oe property

the character used for indenting
See also: indentChars
See also: indentSpaces
public $indentChar

$indentChars public_oe property

allowable characters for indenting
public $indentChars

$indentSpaces public_oe property

number of spaces for indentation. Used to calculate {@link Level} if {@link indentChar} is space.
public $indentSpaces

$instance public_oe static_oe property

Static holder for last instance of a SassParser
public static $instance

$line public_oe property

line:
public $line

$line_numbers public_oe property

line_numbers:
See also: debug_info
See also: style
public $line_numbers

$load_path_functions public_oe property

public $load_path_functions

$load_paths public_oe property

load_paths:
public $load_paths

$property_syntax public_oe property

property_syntax:
public $property_syntax

$quiet public_oe property

quiet:
public $quiet

$source public_oe property

source
public $source

$style public_oe property

style:
public $style

$syntax public_oe property

syntax:
public $syntax