快捷标签

Testing Is Documentation

tests/View/Compiler/CompilerQuickTest.php快捷标签 - 图1

为了使得模板定义更加简洁,系统还支持一些常用的变量输出快捷标签。

# 注释标签

模板中的注释仅供模板制作人员查看,最终不会显示出来。

  1. public function testBaseUse(): void
  2. {
  3. $parser = $this->createParser();
  4. $source = <<<'eot'
  5. {# 我是一个注释 #}
  6. {#
  7. 我是两行注释
  8. Thank U!
  9. #}
  10. eot;
  11. $compiled = <<<'eot'
  12. eot;
  13. $this->assertSame($compiled, $parser->doCompile($source, null, true));
  14. }

~ 原样 PHP 标签

  1. public function testOriginalPhp(): void
  2. {
  3. $parser = $this->createParser();
  4. $source = <<<'eot'
  5. {~$value = 'Make QueryPHP greater !'}
  6. {$value}
  7. eot;
  8. $compiled = <<<'eot'
  9. <?php $value = 'Make QueryPHP greater !'; ?>
  10. <?php echo $value; ?>
  11. eot;
  12. $this->assertSame($compiled, $parser->doCompile($source, null, true));
  13. }

: echo 快捷方式

  1. public function testEcho(): void
  2. {
  3. $parser = $this->createParser();
  4. $source = <<<'eot'
  5. {:'Hello QueryPHP!'}
  6. eot;
  7. $compiled = <<<'eot'
  8. <?php echo 'Hello QueryPHP!'; ?>
  9. eot;
  10. $this->assertSame($compiled, $parser->doCompile($source, null, true));
  11. }