Include 标签

    1. {
    2. $parser = $this->createParser();
    3. $source = <<<'eot'
    4. <include file="application/app/ui/theme/default/header.html">
    5. eot;
    6. $compiled = <<<'eot'
    7. <?php $this->display('application/app/ui/theme/default/header', [], '.html', true); ?>
    8. eot;
    9. }
    1. public function testInViewDir()
    2. {
    3. $parser = $this->createParser();
    4. <include file="test" />
    5. eot;
    6. $compiled = <<<'eot'
    7. <?php $this->display('test', [], '', true); ?>
    8. eot;
    9. $this->assertSame($compiled, $parser->doCompile($source, null, true));
    10. }
    1. public function testExpr()
    2. {
    3. // 防止 . 被替换加上 () 包裹起来
    4. $source = <<<'eot'
    5. <include file="($path . '/' . $name)" />
    6. <include file="Template::tpl('header')" />
    7. <include file="tpl('header')" />
    8. <include file="$hello.world('header')" />
    9. eot;
    10. $compiled = <<<'eot'
    11. <?php $this->display(($path . '/' . $name), [], '', true); ?>
    12. <?php $this->display(Template::tpl('header'), [], '', true); ?>
    13. <?php $this->display(tpl('header'), [], '', true); ?>
    14. <?php $this->display($hello->world('header'), [], '', true); ?>
    15. eot;
    16. $this->assertSame($compiled, $parser->doCompile($source, null, true));