PHP Class Haanga

Simple class to call templates efficiently. This class aims to reduce the compilation of a template as less a possible. Also it will not load in memory the compiler, except when there is not cache (compiled template) or it is out-dated.
ファイルを表示 Open project: crodas/haanga Class Usage Examples

Public Properties

Property Type Description
$has_compiled

Protected Properties

Property Type Description
$bootstrap
$cache_dir
$check_get
$check_set
$check_ttl
$compiler
$debug
$hash_filename
$templates_dir
$use_autoload

Public Methods

Method Description
Load ( string $file, array $vars = [], boolean $return = FALSE, array $blocks = [] ) : string | null Load
Safe_Load ( $file, $vars = [], $return = FALSE, $blocks = [] ) safe_load(string $file, array $vars, bool $return, array $blocks) {{{
checkCacheDir ( ) : void Check the directory where the compiled templates are stored.
compile ( string $tpl, array $context = [] ) : callback($vars=array(), Compile one template and return a PHP function
configure ( array $opts ) : void Configuration to load Haanga
enableDebug ( $bool ) enableDebug($bool) {{{
getTemplateDir ( )
getTemplatePath ( $file ) }}}

Protected Methods

Method Description
getCompiler ( boolean $checkdir = TRUE ) : Haanga_Compiler_Runtime This function is a singleton for the Haanga_Compiler_Runtime class.

Private Methods

Method Description
__construct ( )

Method Details

Load() public static method

Load template. If the template is already compiled, just the compiled PHP file will be included an used. If the template is new, or it had changed, the Haanga compiler is loaded in memory, and the template is compiled.
public static Load ( string $file, array $vars = [], boolean $return = FALSE, array $blocks = [] ) : string | null
$file string @param array $vars @param bool $return @param array $blocks @return string|NULL
$vars array
$return boolean
$blocks array
return string | null

Safe_Load() public static method

safe_load(string $file, array $vars, bool $return, array $blocks) {{{
public static Safe_Load ( $file, $vars = [], $return = FALSE, $blocks = [] )

checkCacheDir() public static method

@param string $dir
public static checkCacheDir ( ) : void
return void

compile() public static method

@param string $tpl Template body
public static compile ( string $tpl, array $context = [] ) : callback($vars=array(),
$tpl string
$context array Context variables useful to generate efficient code (for array, objects and array) @return callback($vars=array(), $return=TRUE, $block=array())
return callback($vars=array(),

configure() final public static method

Options: - (string) cache_dir - (string) tempalte_dir - (callback) on_compile - (boolean) debug - (int) check_ttl - (callback) check_get - (callback) check_set - (boolean) autoload - (boolean) use_hash_filename
final public static configure ( array $opts ) : void
$opts array
return void

enableDebug() public static method

enableDebug($bool) {{{
public static enableDebug ( $bool )

getCompiler() protected static method

The instance is already set up properly and resetted.
protected static getCompiler ( boolean $checkdir = TRUE ) : Haanga_Compiler_Runtime
$checkdir boolean TRUE @return Haanga_Compiler_Runtime
return Haanga_Compiler_Runtime

getTemplateDir() public static method

public static getTemplateDir ( )

getTemplatePath() public static method

}}}
public static getTemplatePath ( $file )

Property Details

$bootstrap protected_oe static_oe property

protected static $bootstrap

$cache_dir protected_oe static_oe property

protected static $cache_dir

$check_get protected_oe static_oe property

protected static $check_get

$check_set protected_oe static_oe property

protected static $check_set

$check_ttl protected_oe static_oe property

protected static $check_ttl

$compiler protected_oe static_oe property

protected static $compiler

$debug protected_oe static_oe property

protected static $debug

$has_compiled public_oe static_oe property

public static $has_compiled

$hash_filename protected_oe static_oe property

protected static $hash_filename

$templates_dir protected_oe static_oe property

protected static $templates_dir

$use_autoload protected_oe static_oe property

protected static $use_autoload