DictPrefTemplate.php 798 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. * 词典前缀列表组件:`{{dict-pref|page|size}}`(缺省第 1 页、每页 100)。
  7. */
  8. final class DictPrefTemplate extends Template
  9. {
  10. protected string $component = 'dict-pref';
  11. public function params(): array
  12. {
  13. return ['page' => ParamSpec::at(1, '1'), 'size' => ParamSpec::at(2, '100')];
  14. }
  15. /**
  16. * @return array<string, mixed>
  17. */
  18. public function props(Call $call, RenderContext $ctx): array
  19. {
  20. return ['currPage' => (int) $call->param('page'), 'pageSize' => (int) $call->param('size')];
  21. }
  22. public function text(Call $call, RenderContext $ctx): string
  23. {
  24. return 'dict-pref';
  25. }
  26. }