PHP Class Jade\Compiler\CompilerUtils

Internal static methods of the compiler.
Inheritance: extends Jade\Compiler\Indenter
Show file Open project: kylekatarnls/jade-php

Protected Methods

Method Description
addDollarIfNeeded ( string $call ) : string Prepend "$" to the given input if it's a varname.
convertVarPath ( string $arg, string $regexp = '/^%s|,%s/' ) : string Replace var paths in a string.
convertVarPathCallback ( array $match ) : string Return PHP code to translate dot to object/array getter.
decodeAttributes ( array $attributes ) : array Decode each attribute in the given list.
decodeValue ( string $value ) : mixed Decode a value (parse it except if it's null).
escapeIfNeeded ( boolean $escaped, mixed $value ) : callable Return PHP code wich wrap the given value and escape it if $escaped is true.
escapeValue ( string $val ) : string Escape value depanding on the current quote.
getFilter ( string $name ) : callable Get filter by name.
initArgToNull ( &string &$arg ) Concat " = null" to initializations to simulate the JS "var foo;".
joinAny ( array $value ) : string | mixed Join with space if the value is an array, else return the input value with no changes.
parseValue ( string $value ) : mixed Parse a value from its quoted string (or JSON) representation.

Method Details

addDollarIfNeeded() protected static method

Prepend "$" to the given input if it's a varname.
protected static addDollarIfNeeded ( string $call ) : string
$call string
return string

convertVarPath() protected static method

Replace var paths in a string.
protected static convertVarPath ( string $arg, string $regexp = '/^%s|,%s/' ) : string
$arg string
$regexp string
return string

convertVarPathCallback() protected static method

Return PHP code to translate dot to object/array getter.
protected static convertVarPathCallback ( array $match ) : string
$match array regex match
return string

decodeAttributes() protected static method

Decode each attribute in the given list.
protected static decodeAttributes ( array $attributes ) : array
$attributes array
return array

decodeValue() protected static method

Decode a value (parse it except if it's null).
protected static decodeValue ( string $value ) : mixed
$value string
return mixed

escapeIfNeeded() protected method

Return PHP code wich wrap the given value and escape it if $escaped is true.
protected escapeIfNeeded ( boolean $escaped, mixed $value ) : callable
$escaped boolean need to be escaped
$value mixed to be escaped if $escaped is true
return callable

escapeValue() protected method

Escape value depanding on the current quote.
protected escapeValue ( string $val ) : string
$val string input value
return string

getFilter() protected method

Get filter by name.
protected getFilter ( string $name ) : callable
$name string
return callable

initArgToNull() protected static method

Concat " = null" to initializations to simulate the JS "var foo;".
protected static initArgToNull ( &string &$arg )
$arg &string

joinAny() protected static method

Join with space if the value is an array, else return the input value with no changes.
protected static joinAny ( array $value ) : string | mixed
$value array
return string | mixed

parseValue() protected static method

Parse a value from its quoted string (or JSON) representation.
protected static parseValue ( string $value ) : mixed
$value string
return mixed