Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions _build/_theme/_exts/symfonycom/sphinx/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,20 @@ class TerminalLexer(RegexLexer):
('(.+)$', bygroups(using(BatchLexer)), '#pop')
],
}


class NonCopyDiffLexer(RegexLexer):
name = 'NonCopyDiff'
aliases = ['non-copy-diff']
filenames = []

tokens = {
'root': [
('^\+ ', Generic.DiffIndicator, 'inserted'),
('^- ', Generic.DiffIndicator, 'deleted'),
('^ ', Generic.DiffIndicator, 'text')
],
'inserted': [('.+$', Generic.Inserted)],
'deleted': [('.+$', Generic.Deleted)],
'text': [('.+$', Text)]
}
3 changes: 2 additions & 1 deletion _build/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from pygments.lexers.special import TextLexer
from pygments.lexers.text import RstLexer
from pygments.lexers.web import PhpLexer
from symfonycom.sphinx.lexer import TerminalLexer
from symfonycom.sphinx.lexer import TerminalLexer, NonCopyDiffLexer

# -- General configuration -----------------------------------------------------

Expand Down Expand Up @@ -110,6 +110,7 @@
lexers['varnish3'] = CLexer()
lexers['varnish4'] = CLexer()
lexers['terminal'] = TerminalLexer()
lexers['diff'] = NonCopyDiffLexer()

config_block = {
'markdown': 'Markdown',
Expand Down
40 changes: 21 additions & 19 deletions page_creation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,25 +114,27 @@ First, make sure that ``LuckyController`` extends Symfony's base
}

Now, use the handy ``render()`` function to render a template. Pass it our ``number``
variable so we can render that::

// src/AppBundle/Controller/LuckyController.php
// ...

class LuckyController extends Controller
{
/**
* @Route("/lucky/number")
*/
public function numberAction()
{
$number = mt_rand(0, 100);

return $this->render('lucky/number.html.twig', array(
'number' => $number,
));
}
}
variable so we can render that:

.. code-block:: diff

// src/AppBundle/Controller/LuckyController.php
// ...

class LuckyController extends Controller
{
/**
* @Route("/lucky/number")
*/
public function numberAction()
{
+ $number = mt_rand(0, 100);

+ return $this->render('lucky/number.html.twig', array(
+ 'number' => $number,
+ ));
}
}

Finally, template files should live in the ``app/Resources/views`` directory. Create
a new ``app/Resources/views/lucky`` directory with a new ``number.html.twig`` file
Expand Down