schranz-templating/symfony-latte-integration

通过 Latte 模板引擎将模板渲染器集成到 symfony。

0.1.0 2022-09-17 15:53 UTC

This package is auto-updated.

Last update: 2024-08-29 05:56:17 UTC


README

将模板适配器 Latte Adapter 集成到 Symfony 框架中。

Schranz 模板项目 的一部分。

安装

通过 Composer 安装此包

composer require schranz-templating/symfony-latte-integration

在您的 config/bundles.php 或 Kernel 文件中注册 Bundle 类

return [
    // ...
    Schranz\Templating\Integration\Symfony\Latte\SchranzTemplatingLatteBundle::class => ['all' => true],
];

配置

Latte 集成提供以下配置选项:

schranz_templating_latte:
    default_path: '%kernel.project_dir%/templates'
    cache: '%kernel.cache_dir%/latte'

不需要任何配置。

default_path

类型: string 默认值: '%kernel.project_dir%/templates'

默认情况下,Symphony 将在此目录中查找应用程序 Latte 模板。

cache

类型: string 默认值: '%kernel.cache_dir%/latte'

在将 Latte 模板用于渲染内容之前,它们被编译成常规 PHP 代码。编译是一个耗时的过程,因此结果被缓存在此配置选项定义的目录中。

扩展

为了扩展 Latte 功能,您可以创建一个新的服务,该服务扩展自 Latte\Extension。当 autoconfigure 启用时,它将自动标记为 latte.extension 并作为 Latte 扩展添加。如果不这样做,您需要自己标记该服务。

services:
    App\Latte\MyExtension:
        tags:
            - { name: latte.extension }

有关 Latte 扩展的更多信息,请参阅 Latte 文档