https://github.com/inteve/latte
Helper classes for Latte.
https://github.com/inteve/latte
Last synced: 3 months ago
JSON representation
Helper classes for Latte.
- Host: GitHub
- URL: https://github.com/inteve/latte
- Owner: inteve
- License: other
- Created: 2022-04-11T11:14:51.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-12-14T00:45:12.000Z (over 1 year ago)
- Last Synced: 2025-01-13T08:12:24.403Z (5 months ago)
- Language: PHP
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- Funding: .github/funding.yml
- License: license.md
Awesome Lists containing this project
README
# Inteve\Latte
[](https://github.com/inteve/latte/actions)
[](https://packagist.org/packages/inteve/latte)
[](https://github.com/inteve/latte/releases)
[](https://github.com/inteve/latte/blob/master/license.md)Extensions for Latte templates
## Installation
[Download a latest package](https://github.com/inteve/latte/releases) or use [Composer](http://getcomposer.org/):
```
composer require inteve/latte
```Inteve\Latte requires PHP 7.4.0 or later and Latte 2.
## Usage
### Installation of extensions
``` php
\Inteve\Latte\ExtensionInstaller::install($latte, [
new FooExtension,
new BarExtension,
]);
```or via Nette DI extension:
```neon
extensions:
inteve.latte: Inteve\Latte\DIExtensionservices:
- FooExtension
- BarExtension
```### IconExtension
Creates new Latte tag `{icon foo}`. Saves icon code directly to compiled template. Requires implementation PHIG's `HtmlIcons` interface.
```php
\Inteve\Latte\ExtensionInstaller::install($latte, [
new \Inteve\Latte\IconExtension($phigIcons),
]);
``````latte
{icon myIcon}
```### TypographyExtension
Creates new Latte filter `|typography`.
```php
\Inteve\Latte\ExtensionInstaller::install($latte, [
new \Inteve\Latte\TypographyExtension,
]);
``````latte
{='My a text'|typography} {* prints 'My a text' *}
```### Custom extension
Just extends `Inteve\Latte\Extension`:
```php
class MyExtension extends \Inteve\Latte\Extension
{
/**
* @return array
*/
public function getTags(): array
{
return [
function (\Latte\Compiler $compiler) {
$me = new Latte\Macros\MacroSet($compiler);
$me->addMacro('myTag', ['MyLatteMacros', 'macroMyTag']);
},
];
}/**
* @return array
*/
public function getFilters(): array
{
return [
'myFilter' => function ($value) {
return $value,
},
];
}/**
* @return array
*/
public function getProviders(): array
{
return [
'myProvider' => 'foo bar',
];
}
}
```------------------------------
License: [New BSD License](license.md)
Author: Jan Pecha, https://www.janpecha.cz/