mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-16 12:26:30 +00:00
grammar and punctuation fixes
This commit is contained in:
+8
-8
@@ -177,7 +177,7 @@ argument::
|
|||||||
|
|
||||||
$filter = new Twig_SimpleFilter('rot13', 'str_rot13', $options);
|
$filter = new Twig_SimpleFilter('rot13', 'str_rot13', $options);
|
||||||
|
|
||||||
Environment aware Filters
|
Environment-aware Filters
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
If you want to access the current environment instance in your filter, set the
|
If you want to access the current environment instance in your filter, set the
|
||||||
@@ -191,7 +191,7 @@ environment as the first argument to the filter call::
|
|||||||
return str_rot13($string);
|
return str_rot13($string);
|
||||||
}, array('needs_environment' => true));
|
}, array('needs_environment' => true));
|
||||||
|
|
||||||
Context aware Filters
|
Context-aware Filters
|
||||||
~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
If you want to access the current context in your filter, set the
|
If you want to access the current context in your filter, set the
|
||||||
@@ -319,22 +319,22 @@ This is used by many of the tests built into Twig::
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
The above example, shows how you can create tests that use a node class. The
|
The above example shows how you can create tests that use a node class. The
|
||||||
node class has access to one sub-node called 'node'. This sub-node contains the
|
node class has access to one sub-node called 'node'. This sub-node contains the
|
||||||
value that is being tested. When the ``odd`` filter is used in code like:
|
value that is being tested. When the ``odd`` filter is used in code such as:
|
||||||
|
|
||||||
.. code-block:: jinja
|
.. code-block:: jinja
|
||||||
|
|
||||||
{% if my_value is odd %}
|
{% if my_value is odd %}
|
||||||
|
|
||||||
The ``node`` sub-node will contain an expression of ``my_value``. Node based
|
The ``node`` sub-node will contain an expression of ``my_value``. Node-based
|
||||||
tests also have access to the ``arguments`` node. This node will contain the
|
tests also have access to the ``arguments`` node. This node will contain the
|
||||||
various other arguments that have been provided to your test.
|
various other arguments that have been provided to your test.
|
||||||
|
|
||||||
Tags
|
Tags
|
||||||
----
|
----
|
||||||
|
|
||||||
One of the most exciting feature of a template engine like Twig is the
|
One of the most exciting features of a template engine like Twig is the
|
||||||
possibility to define new language constructs. This is also the most complex
|
possibility to define new language constructs. This is also the most complex
|
||||||
feature as you need to understand how Twig's internals work.
|
feature as you need to understand how Twig's internals work.
|
||||||
|
|
||||||
@@ -693,7 +693,7 @@ responsible for parsing the tag and compiling it to PHP.
|
|||||||
Operators
|
Operators
|
||||||
~~~~~~~~~
|
~~~~~~~~~
|
||||||
|
|
||||||
The ``getOperators()`` methods allows to add new operators. Here is how to add
|
The ``getOperators()`` methods lets you add new operators. Here is how to add
|
||||||
``!``, ``||``, and ``&&`` operators::
|
``!``, ``||``, and ``&&`` operators::
|
||||||
|
|
||||||
class Project_Twig_Extension extends Twig_Extension
|
class Project_Twig_Extension extends Twig_Extension
|
||||||
@@ -717,7 +717,7 @@ The ``getOperators()`` methods allows to add new operators. Here is how to add
|
|||||||
Tests
|
Tests
|
||||||
~~~~~
|
~~~~~
|
||||||
|
|
||||||
The ``getTests()`` methods allows to add new test functions::
|
The ``getTests()`` method lets you add new test functions::
|
||||||
|
|
||||||
class Project_Twig_Extension extends Twig_Extension
|
class Project_Twig_Extension extends Twig_Extension
|
||||||
{
|
{
|
||||||
|
|||||||
+3
-3
@@ -3,10 +3,10 @@ Twig Internals
|
|||||||
|
|
||||||
Twig is very extensible and you can easily hack it. Keep in mind that you
|
Twig is very extensible and you can easily hack it. Keep in mind that you
|
||||||
should probably try to create an extension before hacking the core, as most
|
should probably try to create an extension before hacking the core, as most
|
||||||
features and enhancements can be done with extensions. This chapter is also
|
features and enhancements can be handled with extensions. This chapter is also
|
||||||
useful for people who want to understand how Twig works under the hood.
|
useful for people who want to understand how Twig works under the hood.
|
||||||
|
|
||||||
How Twig works?
|
How does Twig work?
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
The rendering of a Twig template can be summarized into four key steps:
|
The rendering of a Twig template can be summarized into four key steps:
|
||||||
@@ -18,7 +18,7 @@ The rendering of a Twig template can be summarized into four key steps:
|
|||||||
for easier processing;
|
for easier processing;
|
||||||
* Then, the **parser** converts the token stream into a meaningful tree
|
* Then, the **parser** converts the token stream into a meaningful tree
|
||||||
of nodes (the Abstract Syntax Tree);
|
of nodes (the Abstract Syntax Tree);
|
||||||
* Eventually, the *compiler* transforms the AST into PHP code;
|
* Eventually, the *compiler* transforms the AST into PHP code.
|
||||||
|
|
||||||
* **Evaluate** the template: It basically means calling the ``display()``
|
* **Evaluate** the template: It basically means calling the ``display()``
|
||||||
method of the compiled template and passing it the context.
|
method of the compiled template and passing it the context.
|
||||||
|
|||||||
Reference in New Issue
Block a user