public function testFetch() { $template = new Template(); $template->tpl_path = dirname(__FILE__) . '/'; $data = ['name' => 'value']; $content = <<<EOF {\$name} EOF; $template->fetch($content, $data); $this->expectOutputString('value'); }
public function testFetch() { $config['view_path'] = dirname(__FILE__) . '/'; $config['view_suffix'] = '.html'; $config['layout_on'] = true; $config['layout_name'] = 'layout'; $template = new Template($config); $files = ['extend' => 'extend', 'include' => 'include']; $template->assign('files', $files); $template->assign('user', ['name' => 'name', 'account' => 100]); $template->assign('message', 'message'); $template->assign('info', ['value' => 'value']); $content = <<<EOF {extend name="\$files.extend" /} {block name="main"} main {block name="side"} {__BLOCK__} {include file="\$files.include" name="\$user.name" value="\$user.account" /} {\$message}{literal}{\$message}{/literal} {/block} {block name="mainbody"} mainbody {/block} {/block} EOF; $content2 = <<<EOF <nav> header <div id="wrap"> <input name="info" value="value"> value: main side <input name="name" value="100"> value: message{\$message} mainbody {\$name} php code</div> </nav> EOF; $template->fetch($content); $this->expectOutputString($content2); // $template->parse($content); // var_dump($content); }