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.
Afficher le fichier Open project: crodas/haanga Class Usage Examples

Méthodes publiques

Свойство Type Description
$has_compiled

Protected Properties

Свойство Type Description
$bootstrap
$cache_dir
$check_get
$check_set
$check_ttl
$compiler
$debug
$hash_filename
$templates_dir
$use_autoload

Méthodes publiques

Méthode 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 ) }}}

Méthodes protégées

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

Private Methods

Méthode Description
__construct ( )

Method Details

Load() public static méthode

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
Résultat string | null

Safe_Load() public static méthode

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

checkCacheDir() public static méthode

@param string $dir
public static checkCacheDir ( ) : void
Résultat void

compile() public static méthode

@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())
Résultat callback($vars=array(),

configure() final public static méthode

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
Résultat void

enableDebug() public static méthode

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

getCompiler() protected static méthode

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
Résultat Haanga_Compiler_Runtime

getTemplateDir() public static méthode

public static getTemplateDir ( )

getTemplatePath() public static méthode

}}}
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