Skip to content

Twig integration for tolkam/routing

Notifications You must be signed in to change notification settings

Tolkam-PHP-Components/routing-twig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tolkam/routing-twig

Twig integration for tolkam/routing.

Documentation

The code is rather self-explanatory and API is intended to be as simple as possible. Please, read the sources/Docblock if you have any questions. See Usage for quick start.

Usage

use Aura\Router\RouterContainer;
use Tolkam\Routing\Adapter\Aura\Adapter\Aura\AuraRouterAdapter;
use Tolkam\Routing\Twig\RoutingExtension;
use Twig\Environment;
use Twig\Loader\ArrayLoader;

$routerContainer = new RouterContainer();
$routerContainer
    ->getMap()
    ->route('my.route', '/my-route-url{/param}');

$twig = new Environment(new ArrayLoader([
    'myTemplate.twig' => 'Route "my.route" URL is "{{ route("my.route", {"param": "value"}) }}"',
]));

$twig->addExtension(new RoutingExtension(new AuraRouterAdapter($routerContainer)));

echo $twig->render('myTemplate.twig');

License

Proprietary / Unlicensed 🤷

About

Twig integration for tolkam/routing

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages