PHP Класс Haanga_Compiler

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$safes
$var_is_safe Flag the current variable as safe. This means that escape won't be called if autoescape is activated (which is activated by default)

Защищенные свойства (Protected)

Свойство Тип Описание
$append
$autoescape * compiler options
$block_var properties {{{
$blocks
$check_function
$context Context at compile time
$debug Debug file
$dot_as_object
$echo_concat
$enable_load
$file
$forid
$forloop
$generator
$global_context
$if_empty
$in_block number of blocks :-)
$is_exec_enabled
$line
$name
$ob_start output buffers :-)
$prepend_op
$strip_whitespace
$sub_template
$var_alias Table which contains all variables aliases defined in the template

Открытые методы

Метод Описание
Error ( $err ) Throw an exception and appends information about the template (the path and the last processed line).
__construct ( ) }}}
compile ( $code, $name = NULL, $file = NULL ) Compile ($code, $name=NULL) {{{
compile_file ( string $file, boolean $safe = FALSE, $context = [] ) : Generated Compile a file
do_filtering ( $name, $args )
do_print ( Haanga_AST $code, $stmt ) Print {{{
expr_call_base_template ( ) Generate code to call base template
generate_op_alias ( $details, &$body )
generate_op_autoescape ( $details, &$body ) autoescape ON|OFF {{{
generate_op_custom_tag ( $details, &$body ) Generate needed code for custom tags (tags that aren't handled by the compiler).
generate_op_filter ( $details, &$body )
generate_op_set ( $details, &$body ) }}}
generate_op_spacefull ( $details, &$body ) {% spacefull %} Set to OFF strip_whitespace for a block (the compiler option) {{{
generate_variable_name ( $variable, $special = true ) Get variable name {{{
getOpCodes ( string $code, string $file ) : Haanga_AST Compile the $code and return the "opcodes" (the Abstract syntax tree).
getOption ( $option ) getOption($option) {{{
getScopeVariable ( $part = NULL, $string = FALSE )
get_base_template ( array $base ) : string Handle {% base "" %} definition. By default only static (string) are supported, but this can be overrided on subclasses.
get_context ( $variable )
get_custom_filter ( $name ) Custom Filters {{{
get_custom_tag ( $name ) Custom Tags {{{
get_filtered_var ( array $variable, &$varname, boolean $accept_string = NULL ) : expr This method handles all the filtered variable (piped_list(X)'s output in the parser.
get_function_name ( $name ) get_function_name(string $name) {{{
get_template_name ( ) get_template_name() {{{
isMethod ( $varname, &$expr ) }}}
is_safe ( $name )
is_var_filter ( $cmd ) is_expr methods {{{
main_cli ( ) * }}}
ob_start ( &$body ) Start a new buffering
reset ( ) reset() {{{
setDebug ( $file ) setDebug($file) {{{
setOption ( $option, $value ) : void Set Compiler option.
set_context ( $varname, $value ) Variables context
set_safe ( $name ) * variable safety {{{
set_template_name ( $path ) Set template name {{{
set_unsafe ( $name )
var_is_object ( array $variable, $default = NULL )

Защищенные методы

Метод Описание
check_expr ( &$expr ) Check the current expr {{{
compile_required_template ( $file ) Override template {{{
generate_op_base ( ) {% base "foo.html" %} {{{
generate_op_block ( $details, &$body ) {% block 'name' %} .
generate_op_code ( $parsed, &$body ) Main Loop {{{
generate_op_comment ( $details, &$body ) {# something #} {{{
generate_op_html ( $details, &$body ) Handle HTML code {{{
generate_op_if ( $details, &$body ) {% if %} HTML {% else %} TWO {% endif $} {{{
generate_op_ifchanged ( $details, &$body ) ifchanged [
generate_op_ifequal ( $details, &$body ) ifequal|ifnot equal .
generate_op_include ( $details, &$body ) include "file.html" | include {{{
generate_op_loop ( $details, &$body ) for [,] in {{{
generate_op_print_var ( $details, &$body ) Generate code to print a variable with its filters, if there is any.
generate_op_regroup ( $details, &$body ) regroup by as {{{

Описание методов

Error() публичный Метод

Throw an exception and appends information about the template (the path and the last processed line).
public Error ( $err )

__construct() публичный Метод

}}}
public __construct ( )

check_expr() защищенный Метод

Check the current expr {{{
protected check_expr ( &$expr )

compile() закрытый публичный Метод

Compile ($code, $name=NULL) {{{
final public compile ( $code, $name = NULL, $file = NULL )

compile_file() закрытый публичный Метод

@param string $file File path
final public compile_file ( string $file, boolean $safe = FALSE, $context = [] ) : Generated
$file string
$safe boolean Whether or not add check if the function is already defined @return Generated PHP code
Результат Generated

compile_required_template() защищенный Метод

Override template {{{
protected compile_required_template ( $file )

do_filtering() публичный Метод

public do_filtering ( $name, $args )

do_print() публичный Метод

Print {{{
public do_print ( Haanga_AST $code, $stmt )
$code Haanga_AST

expr_call_base_template() публичный Метод

Generate code to call base template

generate_op_alias() публичный Метод

public generate_op_alias ( $details, &$body )

generate_op_autoescape() публичный Метод

autoescape ON|OFF {{{
public generate_op_autoescape ( $details, &$body )

generate_op_base() защищенный Метод

{% base "foo.html" %} {{{
protected generate_op_base ( )

generate_op_block() защищенный Метод

.. {% endblock %} {{{
protected generate_op_block ( $details, &$body )

generate_op_code() защищенный Метод

Main Loop {{{
protected generate_op_code ( $parsed, &$body )

generate_op_comment() защищенный Метод

{# something #} {{{
protected generate_op_comment ( $details, &$body )

generate_op_custom_tag() публичный Метод

Generate needed code for custom tags (tags that aren't handled by the compiler).
public generate_op_custom_tag ( $details, &$body )

generate_op_filter() публичный Метод

public generate_op_filter ( $details, &$body )

generate_op_html() защищенный Метод

Handle HTML code {{{
protected generate_op_html ( $details, &$body )

generate_op_if() защищенный Метод

{% if %} HTML {% else %} TWO {% endif $} {{{
protected generate_op_if ( $details, &$body )

generate_op_ifchanged() защищенный Метод

ifchanged [
protected generate_op_ifchanged ( $details, &$body )

generate_op_ifequal() защищенный Метод

.. else ... {{{
protected generate_op_ifequal ( $details, &$body )

generate_op_include() защищенный Метод

include "file.html" | include {{{
protected generate_op_include ( $details, &$body )

generate_op_loop() защищенный Метод

for [,] in {{{
protected generate_op_loop ( $details, &$body )

generate_op_print_var() защищенный Метод

All variable (except those flagged as |safe) are automatically escaped if autoescape is "on".
protected generate_op_print_var ( $details, &$body )

generate_op_regroup() защищенный Метод

regroup by as {{{
protected generate_op_regroup ( $details, &$body )

generate_op_set() публичный Метод

}}}
public generate_op_set ( $details, &$body )

generate_op_spacefull() публичный Метод

{% spacefull %} Set to OFF strip_whitespace for a block (the compiler option) {{{
public generate_op_spacefull ( $details, &$body )

generate_variable_name() публичный Метод

Get variable name {{{
public generate_variable_name ( $variable, $special = true )

getOpCodes() публичный Метод

@param string $code Template content
public getOpCodes ( string $code, string $file ) : Haanga_AST
$code string
$file string File path (used for erro reporting) @return Haanga_AST
Результат Haanga_AST

getOption() публичный статический Метод

getOption($option) {{{
public static getOption ( $option )

getScopeVariable() публичный Метод

public getScopeVariable ( $part = NULL, $string = FALSE )

get_base_template() публичный Метод

This method load the base class, compile it and return the generated code.
public get_base_template ( array $base ) : string
$base array Base structure @return string Generated source code
Результат string

get_context() публичный Метод

public get_context ( $variable )

get_custom_filter() публичный Метод

Custom Filters {{{
public get_custom_filter ( $name )

get_custom_tag() публичный Метод

Custom Tags {{{
public get_custom_tag ( $name )

get_filtered_var() публичный Метод

@param array $variable (Output of piped_list(B) (parser))
public get_filtered_var ( array $variable, &$varname, boolean $accept_string = NULL ) : expr
$variable array
$accept_string boolean
Результат expr

get_function_name() публичный Метод

get_function_name(string $name) {{{
public get_function_name ( $name )

get_template_name() закрытый публичный Метод

get_template_name() {{{
final public get_template_name ( )

isMethod() публичный Метод

}}}
public isMethod ( $varname, &$expr )

is_safe() публичный Метод

public is_safe ( $name )

is_var_filter() публичный Метод

is_expr methods {{{
public is_var_filter ( $cmd )

main_cli() закрытый статический публичный Метод

* }}}
final static public main_cli ( )

ob_start() публичный Метод

Start a new buffering
public ob_start ( &$body )

reset() публичный Метод

reset() {{{
public reset ( )

setDebug() публичный Метод

setDebug($file) {{{
public setDebug ( $file )

setOption() публичный статический Метод

@return void
public static setOption ( $option, $value ) : void
Результат void

set_context() публичный Метод

These two functions are useful to detect if a variable separated by dot (foo.bar) is an array or object. To avoid overhead we decide it at compile time, rather than ask over and over at rendering time. foo.bar: + If foo exists at compile time, and it is an array, it would be foo['bar'] otherwise it'd be foo->bar. + If foo don't exists at compile time, it would be foo->bar if the compiler option dot_as_object is TRUE (by default) otherwise it'd be foo['bar']
Автор: crodas @author gallir (ideas)
public set_context ( $varname, $value )

set_safe() публичный Метод

* variable safety {{{
public set_safe ( $name )

set_template_name() публичный Метод

Set template name {{{
public set_template_name ( $path )

set_unsafe() публичный Метод

public set_unsafe ( $name )

var_is_object() публичный Метод

public var_is_object ( array $variable, $default = NULL )
$variable array

Описание свойств

$append защищенное свойство

protected $append

$autoescape защищенное статическое свойство

* compiler options
protected static $autoescape

$block_var защищенное статическое свойство

properties {{{
protected static $block_var

$blocks защищенное свойство

protected $blocks

$check_function защищенное свойство

protected $check_function

$context защищенное свойство

Context at compile time
protected $context

$debug защищенное свойство

Debug file
protected $debug

$dot_as_object защищенное статическое свойство

protected static $dot_as_object

$echo_concat защищенное статическое свойство

protected static $echo_concat

$enable_load защищенное статическое свойство

protected static $enable_load

$file защищенное свойство

protected $file

$forid защищенное свойство

protected $forid

$forloop защищенное свойство

protected $forloop

$generator защищенное свойство

protected $generator

$global_context защищенное статическое свойство

protected static $global_context

$if_empty защищенное статическое свойство

protected static $if_empty

$in_block защищенное свойство

number of blocks :-)
protected $in_block

$is_exec_enabled защищенное статическое свойство

protected static $is_exec_enabled

$line защищенное свойство

protected $line

$name защищенное свойство

protected $name

$ob_start защищенное свойство

output buffers :-)
protected $ob_start

$prepend_op защищенное свойство

protected $prepend_op

$safes публичное свойство

public $safes

$strip_whitespace защищенное статическое свойство

protected static $strip_whitespace

$sub_template защищенное свойство

protected $sub_template

$var_alias защищенное свойство

Table which contains all variables aliases defined in the template
protected $var_alias

$var_is_safe публичное свойство

Flag the current variable as safe. This means that escape won't be called if autoescape is activated (which is activated by default)
public $var_is_safe