data['tpl'] = $resolver->loader(TplLoader::class)->request($call->name, $call->params->all(), $call->scope); } /** * @return array{content: string, document: ?Document}|null */ private function resolved(Call $call, RenderContext $ctx): ?array { return $ctx->loader(TplLoader::class)->result((string) ($call->data['tpl'] ?? '')); } /** * @return array */ public function props(Call $call, RenderContext $ctx): array { return ['name' => $call->name]; } public function children(Call $call, RenderContext $ctx): ?Document { return $this->resolved($call, $ctx)['document'] ?? null; } private function rendered(Call $call, RenderContext $ctx): string { $resolved = $this->resolved($call, $ctx); if ($resolved === null) { return ''; } return $resolved['document'] === null ? $resolved['content'] : $ctx->renderString($resolved['document']); } public function text(Call $call, RenderContext $ctx): string { return $this->rendered($call, $ctx); } public function plain(Call $call, RenderContext $ctx, Format $format): string { return $this->rendered($call, $ctx); } public function html(Call $call, RenderContext $ctx): string { $resolved = $this->resolved($call, $ctx); if ($resolved === null) { return ''; } return $resolved['document'] === null ? e($resolved['content']) : $ctx->renderString($resolved['document']); } public function markdown(Call $call, RenderContext $ctx): string { return $this->rendered($call, $ctx); } }