* ``Twig_Token::EOF_TYPE``: Ends of template.
You can manually convert a source code into a token stream by calling the
-``tokenize()`` of an environment::
+``tokenize()`` method of an environment::
$stream = $twig->tokenize($source, $identifier);
.. note::
- You can change the default lexer use by Twig (``Twig_Lexer``) by calling
+ The default lexer (``Twig_Lexer``) can be changed by calling
the ``setLexer()`` method::
$twig->setLexer($lexer);
.. note::
- The default parser (``Twig_TokenParser``) can be also changed by calling the
+ The default parser (``Twig_TokenParser``) can be changed by calling the
``setParser()`` method::
$twig->setParser($parser);
The last step is done by the compiler. It takes a node tree as an input and
generates PHP code usable for runtime execution of the template.
-You can call the compiler by hand with the ``compile()`` method of an
-environment::
+You can manually compile a node tree to PHP code with the ``compile()`` method
+of an environment::
$php = $twig->compile($nodes);
-The ``compile()`` method returns the PHP source code representing the node.
-
The generated template for a ``Hello {{ name }}`` template reads as follows
(the actual output can differ depending on the version of Twig you are
using)::
.. note::
- As for the lexer and the parser, the default compiler (``Twig_Compiler``) can
- be changed by calling the ``setCompiler()`` method::
+ The default compiler (``Twig_Compiler``) can be changed by calling the
+ ``setCompiler()`` method::
$twig->setCompiler($compiler);