Skip to content

Commit a1f194d

Browse files
authored
Merge pull request #412 from jmsche/docs
Fix docs link & format docs for correct display on Github
2 parents 5cd9c7b + bba27df commit a1f194d

File tree

3 files changed

+53
-52
lines changed

3 files changed

+53
-52
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This is a port of the _symfony 1.x_ plugin: [chCmsExposeRoutingPlugin](https://g
1414
Documentation
1515
-------------
1616

17-
For documentation, see:
17+
For documentation, see: [Resources/doc/index.rst](Resources/doc/index.rst).
1818

1919
[https://symfony.com/doc/master/bundles/FOSJsRoutingBundle/index.html](https://symfony.com/doc/master/bundles/FOSJsRoutingBundle/index.html)
2020

Resources/doc/index.rst

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ FOSJsRoutingBundle
44
This bundle allows to expose Symfony Routes to JavaScript, so you can generate
55
relative or absolute URLs in the browser using the same routes as in the backend.
66

7-
.. toctree::
8-
:maxdepth: 1
9-
10-
installation
11-
usage
12-
commands
7+
* `Installation <installation.rst>`_
8+
* `Usage <usage.rst>`_
9+
* `Commands <commands.rst>`_

Resources/doc/usage.rst

Lines changed: 49 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@ Usage
33

44
In applications not using webpack add these two lines in your layout:
55

6-
.. configuration-block::
6+
**With Twig:**
77

8-
.. code-block:: html+twig
8+
.. code-block:: twig
99
10-
<script src="{{ asset('bundles/fosjsrouting/js/router.min.js') }}"></script>
11-
<script src="{{ path('fos_js_routing_js', { callback: 'fos.Router.setData' }) }}"></script>
10+
<script src="{{ asset('bundles/fosjsrouting/js/router.min.js') }}"></script>
11+
<script src="{{ path('fos_js_routing_js', { callback: 'fos.Router.setData' }) }}"></script>
1212
13-
.. code-block:: html+php
13+
**With PHP:**
1414

15-
<script src="<?php echo $view['assets']->getUrl('bundles/fosjsrouting/js/router.js') ?>"></script>
16-
<script src="<?php echo $view['router']->generate('fos_js_routing_js', array('callback' => 'fos.Router.setData')) ?>"></script>
15+
.. code-block:: html+php
16+
17+
<script src="<?php echo $view['assets']->getUrl('bundles/fosjsrouting/js/router.js') ?>"></script>
18+
<script src="<?php echo $view['router']->generate('fos_js_routing_js', array('callback' => 'fos.Router.setData')) ?>"></script>
1719

1820
.. note::
1921

@@ -65,44 +67,46 @@ Or if you want to generate **absolute URLs**:
6567
6668
Assuming some route definitions:
6769

68-
.. configuration-block::
69-
70-
.. code-block:: php-annotations
71-
72-
// src/AppBundle/Controller/DefaultController.php
73-
74-
/**
75-
* @Route("/foo/{id}/bar", options={"expose"=true}, name="my_route_to_expose")
76-
*/
77-
public function indexAction($foo) {
78-
// ...
79-
}
80-
81-
/**
82-
* @Route("/blog/{page}",
83-
* defaults = { "page" = 1 },
84-
* options = { "expose" = true },
85-
* name = "my_route_to_expose_with_defaults",
86-
* )
87-
*/
88-
public function blogAction($page) {
89-
// ...
90-
}
91-
92-
.. code-block:: yaml
93-
94-
# app/config/routing.yml
95-
my_route_to_expose:
96-
pattern: /foo/{id}/bar
97-
defaults: { _controller: AppBundle:Default:index }
98-
options:
99-
expose: true
100-
101-
my_route_to_expose_with_defaults:
102-
pattern: /blog/{page}
103-
defaults: { _controller: AppBundle:Default:blog, page: 1 }
104-
options:
105-
expose: true
70+
**With annotations:**
71+
72+
.. code-block:: php
73+
74+
// src/AppBundle/Controller/DefaultController.php
75+
76+
/**
77+
* @Route("/foo/{id}/bar", options={"expose"=true}, name="my_route_to_expose")
78+
*/
79+
public function indexAction($foo) {
80+
// ...
81+
}
82+
83+
/**
84+
* @Route("/blog/{page}",
85+
* defaults = { "page" = 1 },
86+
* options = { "expose" = true },
87+
* name = "my_route_to_expose_with_defaults",
88+
* )
89+
*/
90+
public function blogAction($page) {
91+
// ...
92+
}
93+
94+
**With YAML:**
95+
96+
.. code-block:: yaml
97+
98+
# app/config/routing.yml
99+
my_route_to_expose:
100+
pattern: /foo/{id}/bar
101+
defaults: { _controller: AppBundle:Default:index }
102+
options:
103+
expose: true
104+
105+
my_route_to_expose_with_defaults:
106+
pattern: /blog/{page}
107+
defaults: { _controller: AppBundle:Default:blog, page: 1 }
108+
options:
109+
expose: true
106110
107111
You can use the ``generate()`` method that way:
108112

0 commit comments

Comments
 (0)