UnknownTemplate.php 732 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace App\Services\Markup\Templates;
  3. use App\Services\Markup\Ir\Call;
  4. use App\Services\Markup\Render\RenderContext;
  5. /**
  6. * 没登记的模板名:tree 输出 `unknown` 组件(带名字),其余格式原样输出源码,不吞内容。
  7. */
  8. final class UnknownTemplate extends Template
  9. {
  10. protected string $component = 'unknown';
  11. protected function acceptsAnyName(): bool
  12. {
  13. return true;
  14. }
  15. /**
  16. * @return array<string, mixed>
  17. */
  18. public function props(Call $call, RenderContext $ctx): array
  19. {
  20. return ['name' => $call->name, 'source' => $call->raw];
  21. }
  22. public function text(Call $call, RenderContext $ctx): string
  23. {
  24. return $call->raw;
  25. }
  26. }