private function extractInclude($psContent) { preg_match_all('#{{include file="([a-zA-Z0-9_/\\.]*)"}}#', $psContent, $arrResult); if (!empty($arrResult[0])) { #echo '<pre>'.print_r($arrResult, true).'</pre>'; foreach ($arrResult[1] as $key => $sFileInclude) { $oYATS = new YATSPHP(); $sDocRoot = null; if (is_null($this->docroot)) { $sDocRoot = dirname($this->template) . DIRECTORY_SEPARATOR; } else { if (substr($sFileInclude, 0, 2) == './') { $sDocRoot = dirname($this->template) . DIRECTORY_SEPARATOR; $sFileInclude = substr($sFileInclude, 2); } else { $sDocRoot = $this->docroot; } } $oYATS->define($sFileInclude, $sDocRoot, $this->searchpath); $oYATS->assign($this->vars); $sInclude = $oYATS->render(); $psContent = str_replace($arrResult[0][$key], $sInclude, $psContent); } } return $psContent; }
/** * * @param YATSPHP $template * @param string|array $var * @param $value * @return boolean */ function yats_assign($template, $var, $value = null) { return $template->assign($var, $value); }