Commit c2d55598 authored by COil's avatar COil Committed by Fabien Potencier

added a Twig example for the service

parent 76f82f20
......@@ -47,3 +47,19 @@ The UrlGenerator provider provides a ``url_generator`` service::
' | '.
'<a href="'.$app['url_generator']->generate('hello', array('name' => 'Igor')).'">Hello Igor</a>';
});
When using Twig, the service can be used like this::
.. code-block:: jinja
{{ app.url_generator.generate('homepage') }}
Moreover, if you register the ``SymfonyBridgesServiceProvider``, then you will have access to the native Twig helpers: ``path()`` and ``url()``::
.. code-block:: jinja
{{ path('homepage') }}
{{ url('homepage') }} {# generates the absolute url http://example.org/ #}
You can find more information about this subject in the :doc:`Symfony bridges documentation<symfony_bridges>`.
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment