$optional 有值才写进 props 的参数,按顺序 * @return array */ protected function embedProps(Call $call, string $type, string $id, array $optional): array { $props = ['type' => $type, 'id' => $id]; // style 为空时不给:前端组件用它自己的默认值(modal),传空串反而什么都不渲染 foreach ($optional as $name) { $value = $name === 'title' ? $this->title($call) : (string) $call->param($name); if ($value !== '') { $props[$name] = $value; } } $props['parentChannels'] = $call->scope->channels; return $props; } /** * 显示的标题(props 与纯文本共用);嵌入经文的模板按 {@see CitesParagraph} 补缺省标题。 */ protected function title(Call $call): string { return (string) $call->param('title'); } public function plain(Call $call, RenderContext $ctx, Format $format): string { return $format === Format::Prompt ? '' : $this->title($call); } public function html(Call $call, RenderContext $ctx): string { return ''; } }