Skip to content

Commit dca6fec

Browse files
committed
minor #7027 Remove dash prefix from route name (bocharsky-bw)
This PR was merged into the 2.7 branch. Discussion ---------- Remove dash prefix from route name Actually, in most cases, the `_` prefix means something internal and probably better to avoid using it in examples Commits ------- b547804 Remove dash prefix from route name
2 parents 36a06e6 + b547804 commit dca6fec

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

templating.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ the routing configuration. Later, if you want to modify the URL of a particular
578578
page, all you'll need to do is change the routing configuration: the templates
579579
will automatically generate the new URL.
580580

581-
First, link to the "_welcome" page, which is accessible via the following routing
581+
First, link to the "welcome" page, which is accessible via the following routing
582582
configuration:
583583

584584
.. configuration-block::
@@ -593,7 +593,7 @@ configuration:
593593
class WelcomeController extends Controller
594594
{
595595
/**
596-
* @Route("/", name="_welcome")
596+
* @Route("/", name="welcome")
597597
*/
598598
public function indexAction()
599599
{
@@ -604,7 +604,7 @@ configuration:
604604
.. code-block:: yaml
605605
606606
# app/config/routing.yml
607-
_welcome:
607+
welcome:
608608
path: /
609609
defaults: { _controller: AppBundle:Welcome:index }
610610
@@ -617,7 +617,7 @@ configuration:
617617
xsi:schemaLocation="http://symfony.com/schema/routing
618618
http://symfony.com/schema/routing/routing-1.0.xsd">
619619
620-
<route id="_welcome" path="/">
620+
<route id="welcome" path="/">
621621
<default key="_controller">AppBundle:Welcome:index</default>
622622
</route>
623623
</routes>
@@ -629,7 +629,7 @@ configuration:
629629
use Symfony\Component\Routing\RouteCollection;
630630
631631
$collection = new RouteCollection();
632-
$collection->add('_welcome', new Route('/', array(
632+
$collection->add('welcome', new Route('/', array(
633633
'_controller' => 'AppBundle:Welcome:index',
634634
)));
635635
@@ -641,11 +641,11 @@ To link to the page, just use the ``path`` Twig function and refer to the route:
641641

642642
.. code-block:: html+twig
643643

644-
<a href="{{ path('_welcome') }}">Home</a>
644+
<a href="{{ path('welcome') }}">Home</a>
645645

646646
.. code-block:: html+php
647647

648-
<a href="<?php echo $view['router']->generate('_welcome') ?>">Home</a>
648+
<a href="<?php echo $view['router']->generate('welcome') ?>">Home</a>
649649

650650
As expected, this will generate the URL ``/``. Now, for a more complicated
651651
route:
@@ -737,7 +737,7 @@ correctly:
737737

738738
.. code-block:: html+twig
739739

740-
<a href="{{ url('_welcome') }}">Home</a>
740+
<a href="{{ url('welcome') }}">Home</a>
741741

742742
The same can be done in PHP templates by passing a third argument to
743743
the ``generate()`` method:
@@ -749,7 +749,7 @@ correctly:
749749
?>
750750

751751
<a href="<?php echo $view['router']->generate(
752-
'_welcome',
752+
'welcome',
753753
array(),
754754
UrlGeneratorInterface::ABSOLUTE_URL
755755
) ?>">Home</a>

0 commit comments

Comments
 (0)