inteve / latte
Extensions for Latte templates
Fund package maintenance!
Other
Requires
- php: 7.4 - 8.2
- latte/latte: ^2.9
- nette/di: ^2.4.16
- nette/utils: ^2.5.5 || ^3.0 || ^4.0
- phig/phig: ^1.2
Requires (Dev)
- nette/tester: ^2.4
Conflicts
- nette/php-generator: <3.0
This package is auto-updated.
Last update: 2024-11-14 02:50:38 UTC
README
Extensions for Latte templates
Installation
Download a latest package or use Composer:
composer require inteve/latte
Inteve\Latte requires PHP 7.4.0 or later and Latte 2.
Usage
Installation of extensions
\Inteve\Latte\ExtensionInstaller::install($latte, [ new FooExtension, new BarExtension, ]);
or via Nette DI extension:
extensions: inteve.latte: Inteve\Latte\DIExtension services: - FooExtension - BarExtension
IconExtension
Creates new Latte tag {icon foo}
. Saves icon code directly to compiled template. Requires implementation PHIG's HtmlIcons
interface.
\Inteve\Latte\ExtensionInstaller::install($latte, [ new \Inteve\Latte\IconExtension($phigIcons), ]);
{icon myIcon}
TypographyExtension
Creates new Latte filter |typography
.
\Inteve\Latte\ExtensionInstaller::install($latte, [ new \Inteve\Latte\TypographyExtension, ]);
{='My a text'|typography} {* prints 'My a text' *}
Custom extension
Just extends Inteve\Latte\Extension
:
class MyExtension extends \Inteve\Latte\Extension { /** * @return array<callable(\Latte\Compiler):void> */ public function getTags(): array { return [ function (\Latte\Compiler $compiler) { $me = new Latte\Macros\MacroSet($compiler); $me->addMacro('myTag', ['MyLatteMacros', 'macroMyTag']); }, ]; } /** * @return array<string, callable> */ public function getFilters(): array { return [ 'myFilter' => function ($value) { return $value, }, ]; } /** * @return array<string, mixed> */ public function getProviders(): array { return [ 'myProvider' => 'foo bar', ]; } }
License: New BSD License
Author: Jan Pecha, https://www.janpecha.cz/