Without params
<a href="{{ path('homepage') }}">Home</a>
In controller we can difine name for the route via annotation:
class PostController extends AbstractController
{
/**
* @Route("/", name="homepage")
*/
public function homepage()
{
// ..
}
Run the command to see available routes:
php bin/console debug:router
With params
<a href="{{ path('post_show', { slug: 'php-book' }) }}">A PHP Book</a>
<link rel="stylesheet" href="{{ asset('css/styles.css') }}">
Later it will help you easily to place your assets to CDN: https://s2.somecdn.com/css/styles.css
We can inherit content of parent's template:
{% block javascripts %}
{{ parent() }}
<script src="{{ asset('js/article_show.js') }}"></script>
{% endblock %}