vrestihnat/title-control

Nette 控制器,用于管理 HTML 页眉中的标题。

1.0.1 2021-01-17 19:18 UTC

This package is auto-updated.

Last update: 2024-09-25 17:49:05 UTC


README

Build Status Downloads this Month Latest stable

安装

通过 Composer

$ composer require vrestihnat/title-control

用法

首先在您的配置中注册控制器工厂

services:
    -
        implement: Vrestihnat\TitleControl\ITitleControlFactory

在您的演示者中使用控制器工厂

protected function createComponentTitle(): Vrestihnat\TitleControl\TitleControl
{
    $control = $this->titleControlFactory->create();
    $control->setTitle('My title');
    return $control;
}

并在您的 Latte 模板中渲染它

<html>
<head>
    {control title}
</head>
<body>
    ...
</body>
</html>

我们还可以使用分隔符的多标题。默认分隔符是:' | '

    $control->addItem('One')->addItem('Two'); // 'One | Two'

更改分隔符

    $control->setSeparator(' ~ ');

我们还可以使用 nette 翻译器