* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
+
/**
- *
- * You can mark a section of a template to be escaped or not by using the autoescape tag:
- *
+ * Marks a section of a template to be escaped or not.
+ *
* <pre>
* {% autoescape true %}
* Everything will be automatically escaped in this block
* using the js escaping strategy
* {% endautoescape %}
* </pre>
- *
*/
class Twig_TokenParser_AutoEscape extends Twig_TokenParser
{
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
+
/**
- *
- * Blocks are used for inheritance and act as placeholders and replacements at the same time.
+ * Marks a section of a template as being reusable.
*
- *
* <pre>
* {% block head %}
* <link rel="stylesheet" href="style.css" />
* <title>{% block title %}{% endblock %} - My Webpage</title>
* {% endblock %}
* </pre>
- *
- *
- */
+ */
class Twig_TokenParser_Block extends Twig_TokenParser
{
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
+
/**
- *
- * The extends tag can be used to extend a template from another one.
- * You can have multiple of them in a file but only one of them may be executed at the time.
- * There is no support for multiple inheritance.
+ * Extends a template by another one.
*
- *
* <pre>
* {% extends "base.html" %}
* </pre>
- *
- *
- */
+ */
class Twig_TokenParser_Extends extends Twig_TokenParser
{
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
+
/**
- *
- * Filter sections allow you to apply regular Twig filters on a block of template data. Just wrap the code in the special filter section:
+ * Filters a section of a template by applying filters.
*
- *
* <pre>
* {% filter upper %}
* This text becomes uppercase
* {% endfilter %}
* </pre>
- *
- *
*/
class Twig_TokenParser_Filter extends Twig_TokenParser
{
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
+
/**
- *
- * Loop over each item in a sequence. For example, to display a list of users provided in a variable called users:
+ * Loops over each item of a sequence.
*
- *
* <pre>
* <ul>
* {% for user in users %}
* <li>{{ user.username|e }}</li>
* {% endfor %}
- * </ul>
+ * </ul>
* </pre>
- *
- *
- */
+ */
class Twig_TokenParser_For extends Twig_TokenParser
{
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
+
+/**
+ * Imports macros.
+ *
+ * <pre>
+ * {% from 'forms.html' import forms %}
+ * </pre>
+ */
class Twig_TokenParser_From extends Twig_TokenParser
{
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
+
/**
- *
- * The if statement in Twig is comparable with the if statements of PHP. In the simplest form you can use it to test if a variable is not empty:
+ * Tests a condition.
*
* <pre>
* {% if users %}
* </ul>
* {% endif %}
* </pre>
- *
- *
*/
class Twig_TokenParser_If extends Twig_TokenParser
{
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
+
/**
- *
- * Twig supports putting often used code into macros.
- * These macros can go into different templates and get imported from there.
+ * Imports macros.
*
- *
* <pre>
* {% import 'forms.html' as forms %}
* </pre>
- *
- *
*/
class Twig_TokenParser_Import extends Twig_TokenParser
{
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
+
/**
- *
- * The include statement is useful to include a template and return the rendered content of that file into the current namespace:
+ * Includes a template.
*
- *
* <pre>
* {% include 'header.html' %}
* Body
* {% include 'footer.html' %}
* </pre>
- *
- *
*/
class Twig_TokenParser_Include extends Twig_TokenParser
{
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
+
/**
- *
- * Macros are comparable with functions in regular programming languages.
- * They are useful to put often used HTML idioms into reusable elements to not repeat yourself.
- * Here is a small example of a macro that renders a form element:
+ * Defines a macro.
*
- *
* <pre>
* {% macro input(name, value, type, size) %}
* <input type="{{ type|default('text') }}" name="{{ name }}" value="{{ value|e }}" size="{{ size|default(20) }}" />
* {% endmacro %}
* </pre>
- *
- *
*/
class Twig_TokenParser_Macro extends Twig_TokenParser
{
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
+
/**
- * The sandbox extension can be used to evaluate untrusted code. Access to unsafe attributes and methods is prohibited.
- *
+ * Marks a section of a template as untrusted code that must be evaluated in the sandbox mode.
*
* <pre>
* {% sandbox %}
* </pre>
*
* @see http://www.twig-project.org/doc/api.html#sandbox-extension for details
- *
*/
class Twig_TokenParser_Sandbox extends Twig_TokenParser
{
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
+
/**
- *
- * Inside code blocks you can also assign values to variables. Assignments use the set tag and can have multiple targets:
- *
+ * Defines a variable.
+ *
* <pre>
* {% set foo = 'foo' %}
*
*
* {% set foo %}Some content{% endset %}
* </pre>
- *
- *
*/
class Twig_TokenParser_Set extends Twig_TokenParser
{
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
+
/**
- * Use the spaceless tag to remove whitespace between HTML tags:
+ * Remove whitespaces between HTML tags.
*
* <pre>
* {% spaceless %}
* <strong>foo</strong>
* </div>
* {% endspaceless %}
- *
+ *
* {# output will be <div><strong>foo</strong></div> #}
* </pre>
- *
*/
class Twig_TokenParser_Spaceless extends Twig_TokenParser
{
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
+
/**
- * The use statement tells Twig to import the blocks defined in another template into the current template (it’s like macros, but for blocks):
+ * Imports blocks defined in another template into the current template.
*
* <pre>
* {% extends "base.html" %}