schranz-templating/symfony-latte-integration

A integration of template renderer into symfony via latte template engine.

0.1.0 2022-09-17 15:53 UTC

This package is not auto-updated.

Last update: 2022-11-15 20:44:52 UTC


README

Integrate the templating Latte Adapter into the Symfony Framework.

Part of the Schranz Templating Project.

Installation

Install this package via Composer:

composer require schranz-templating/symfony-latte-integration

Register the Bundle class in your config/bundles.php or Kernel file:

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

Configuration

The Latte Integration has the following configuration available:

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

None of the configuration is required.

default_path

type: string default: '%kernel.project_dir%/templates'

The path to the directory where Symfony will look for the application Latte templates by default.

cache

type: string default: '%kernel.cache_dir%/latte'

Before using the Latte templates to render some contents, they are compiled into regular PHP code. Compilation is a costly process, so the result is cached in the directory defined by this configuration option.

Extensions

To extend Latte functionality you can create a new service extending from Latte\Extension which when autoconfigure is enabled automatically be tagged with latte.extension and added as a Latte Extension. If not you need to tag the service yourself:

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

Read more about Latte Extensions in the Latte documentation.