final public function _executeMacroOfTemplate($path, PHPTAL $local_tpl)
    {
        // extract macro source file from macro name, if macro path does not
        // contain filename, then the macro is assumed to be local

        if (preg_match('/^(.*?)\/([a-z0-9_-]*)$/i', $path, $m)) {
            list(, $file, $macroName) = $m;

            if (isset($this->externalMacroTemplatesCache[$file])) {
                $tpl = $this->externalMacroTemplatesCache[$file];
            } else {
                $tpl = clone $this;
                array_unshift($tpl->_repositories, dirname($this->_source->getRealPath()));
                $tpl->setTemplate($file);
                $tpl->prepare();

                // keep it small (typically only 1 or 2 external files are used)
                if (count($this->externalMacroTemplatesCache) > 10) {
                    $this->externalMacroTemplatesCache = array();
                }
                $this->externalMacroTemplatesCache[$file] = $tpl;
            }

            $fun = $tpl->getFunctionName() . '_' . strtr($macroName, "-", "_");
            if (!function_exists($fun)) {
                throw new PHPTAL_MacroMissingException("Macro '$macroName' is not defined in $file", $this->_source->getRealPath());
            }

            $fun($tpl, $this);

        } else {
            // call local macro
            $fun = $local_tpl->getFunctionName() . '_' . strtr($path, "-", "_");
            if (!function_exists($fun)) {
                throw new PHPTAL_MacroMissingException("Macro '$path' is not defined", $local_tpl->_source->getRealPath());
            }
            $fun( $local_tpl, $this);
        }
    }
final public function _executeMacroOfTemplate($path, PHPTAL $local_tpl)
    {
        // extract macro source file from macro name, if macro path does not
        // contain filename, then the macro is assumed to be local

        if (preg_match('/^(.*?)\/([a-z0-9_-]*)$/i', $path, $m)) {
            list(, $file, $macroName) = $m;

            if (isset($this->externalMacroTemplatesCache[$file])) {
                $tpl = $this->externalMacroTemplatesCache[$file];
            } else {
                $tpl = clone $this;
                array_unshift($tpl->_repositories, dirname($this->_source->getRealPath()));
                $tpl->setTemplate($file);
                $tpl->prepare();

                // keep it small (typically only 1 or 2 external files are used)
                if (count($this->externalMacroTemplatesCache) > 10) {
                    $this->externalMacroTemplatesCache = array();
                }
                $this->externalMacroTemplatesCache[$file] = $tpl;
            }

            $fun = $tpl->getFunctionName() . '_' . strtr($macroName, "-", "_");
            if (!function_exists($fun)) {
                throw new PHPTAL_MacroMissingException("Macro '$macroName' is not defined in $file", $this->_source->getRealPath());
            }

            $fun($tpl, $this);

        } else {
            // call local macro
            $fun = $local_tpl->getFunctionName() . '_' . strtr($path, "-", "_");
            if (!function_exists($fun)) {
                throw new PHPTAL_MacroMissingException("Macro '$path' is not defined", $local_tpl->_source->getRealPath());
            }
            $fun( $local_tpl, $this);
        }
    }
final public function _executeMacroOfTemplate ( $ path , PHPTAL $ local_tpl ) { // extract macro source file from macro name, if macro path does not // contain filename, then the macro is assumed to be local if ( preg_match ( '/^(.*?)\/([a-z0-9_-]*)$/i' , $ path , $ m ) ) { list ( , $ file , $ macroName ) = $ m ; if ( isset ( $ this -> externalMacroTemplatesCache [ $ file ] ) ) { $ tpl = $ this -> externalMacroTemplatesCache [ $ file ] ; } else { $ tpl = clone $ this ; array_unshift ( $ tpl -> _repositories , dirname ( $ this -> _source -> getRealPath ( ) ) ) ; $ tpl -> setTemplate ( $ file ) ; $ tpl -> prepare ( ) ; // keep it small (typically only 1 or 2 external files are used) if ( count ( $ this -> externalMacroTemplatesCache ) > 10 ) { $ this -> externalMacroTemplatesCache = array ( ) ; } $ this -> externalMacroTemplatesCache [ $ file ] = $ tpl ; } $ fun = $ tpl -> getFunctionName ( ) . '_' . strtr ( $ macroName , "-" , "_" ) ; if ( ! function_exists ( $ fun ) ) { throw new PHPTAL_MacroMissingException ( "Macro '$macroName' is not defined in $file" , $ this -> _source -> getRealPath ( ) ) ; } $ fun ( $ tpl , $ this ) ; } else { // call local macro $ fun = $ local_tpl -> getFunctionName ( ) . '_' . strtr ( $ path , "-" , "_" ) ; if ( ! function_exists ( $ fun ) ) { throw new PHPTAL_MacroMissingException ( "Macro '$path' is not defined" , $ local_tpl -> _source -> getRealPath ( ) ) ; } $ fun ( $ local_tpl , $ this ) ; } }
This is PHPTAL's internal function that handles
execution of macros from templates.

$this is caller's context (the file where execution had originally started)

@param PHPTAL $local_tpl is PHPTAL instance of the file in which macro is defined
(it will be different from $this if it's external macro call)
@access private
This is PHPTAL s internal function that handles execution of macros from templates .