aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/twig/twig/doc
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/twig/twig/doc')
-rw-r--r--vendor/twig/twig/doc/advanced.rst829
-rw-r--r--vendor/twig/twig/doc/advanced_legacy.rst887
-rw-r--r--vendor/twig/twig/doc/api.rst529
-rw-r--r--vendor/twig/twig/doc/coding_standards.rst101
-rw-r--r--vendor/twig/twig/doc/deprecated.rst98
-rw-r--r--vendor/twig/twig/doc/filters/abs.rst18
-rw-r--r--vendor/twig/twig/doc/filters/batch.rst45
-rw-r--r--vendor/twig/twig/doc/filters/capitalize.rst11
-rw-r--r--vendor/twig/twig/doc/filters/convert_encoding.rst28
-rw-r--r--vendor/twig/twig/doc/filters/date.rst88
-rw-r--r--vendor/twig/twig/doc/filters/date_modify.rst23
-rw-r--r--vendor/twig/twig/doc/filters/default.rst33
-rw-r--r--vendor/twig/twig/doc/filters/escape.rst93
-rw-r--r--vendor/twig/twig/doc/filters/first.rst25
-rw-r--r--vendor/twig/twig/doc/filters/format.rst16
-rw-r--r--vendor/twig/twig/doc/filters/index.rst36
-rw-r--r--vendor/twig/twig/doc/filters/join.rst23
-rw-r--r--vendor/twig/twig/doc/filters/json_encode.rst21
-rw-r--r--vendor/twig/twig/doc/filters/keys.rst11
-rw-r--r--vendor/twig/twig/doc/filters/last.rst25
-rw-r--r--vendor/twig/twig/doc/filters/length.rst12
-rw-r--r--vendor/twig/twig/doc/filters/lower.rst10
-rw-r--r--vendor/twig/twig/doc/filters/merge.rst41
-rw-r--r--vendor/twig/twig/doc/filters/nl2br.rst22
-rw-r--r--vendor/twig/twig/doc/filters/number_format.rst45
-rw-r--r--vendor/twig/twig/doc/filters/raw.rst12
-rw-r--r--vendor/twig/twig/doc/filters/replace.rst19
-rw-r--r--vendor/twig/twig/doc/filters/reverse.rst47
-rw-r--r--vendor/twig/twig/doc/filters/slice.rst70
-rw-r--r--vendor/twig/twig/doc/filters/sort.rst17
-rw-r--r--vendor/twig/twig/doc/filters/split.rst53
-rw-r--r--vendor/twig/twig/doc/filters/striptags.rst15
-rw-r--r--vendor/twig/twig/doc/filters/title.rst11
-rw-r--r--vendor/twig/twig/doc/filters/trim.rst29
-rw-r--r--vendor/twig/twig/doc/filters/upper.rst10
-rw-r--r--vendor/twig/twig/doc/filters/url_encode.rst28
-rw-r--r--vendor/twig/twig/doc/functions/attribute.rst18
-rw-r--r--vendor/twig/twig/doc/functions/block.rst15
-rw-r--r--vendor/twig/twig/doc/functions/constant.rst18
-rw-r--r--vendor/twig/twig/doc/functions/cycle.rst25
-rw-r--r--vendor/twig/twig/doc/functions/date.rst52
-rw-r--r--vendor/twig/twig/doc/functions/dump.rst69
-rw-r--r--vendor/twig/twig/doc/functions/include.rst80
-rw-r--r--vendor/twig/twig/doc/functions/index.rst17
-rw-r--r--vendor/twig/twig/doc/functions/parent.rst20
-rw-r--r--vendor/twig/twig/doc/functions/random.rst29
-rw-r--r--vendor/twig/twig/doc/functions/range.rst45
-rw-r--r--vendor/twig/twig/doc/functions/template_from_string.rst32
-rw-r--r--vendor/twig/twig/doc/index.rst18
-rw-r--r--vendor/twig/twig/doc/internals.rst140
-rw-r--r--vendor/twig/twig/doc/intro.rst164
-rw-r--r--vendor/twig/twig/doc/recipes.rst475
-rw-r--r--vendor/twig/twig/doc/tags/autoescape.rst71
-rw-r--r--vendor/twig/twig/doc/tags/block.rst11
-rw-r--r--vendor/twig/twig/doc/tags/do.rst12
-rw-r--r--vendor/twig/twig/doc/tags/embed.rst178
-rw-r--r--vendor/twig/twig/doc/tags/extends.rst268
-rw-r--r--vendor/twig/twig/doc/tags/filter.rst21
-rw-r--r--vendor/twig/twig/doc/tags/flush.rst17
-rw-r--r--vendor/twig/twig/doc/tags/for.rst172
-rw-r--r--vendor/twig/twig/doc/tags/from.rst8
-rw-r--r--vendor/twig/twig/doc/tags/if.rst43
-rw-r--r--vendor/twig/twig/doc/tags/import.rst57
-rw-r--r--vendor/twig/twig/doc/tags/include.rst86
-rw-r--r--vendor/twig/twig/doc/tags/index.rst24
-rw-r--r--vendor/twig/twig/doc/tags/macro.rst83
-rw-r--r--vendor/twig/twig/doc/tags/sandbox.rst30
-rw-r--r--vendor/twig/twig/doc/tags/set.rst78
-rw-r--r--vendor/twig/twig/doc/tags/spaceless.rst37
-rw-r--r--vendor/twig/twig/doc/tags/use.rst123
-rw-r--r--vendor/twig/twig/doc/tags/verbatim.rst24
-rw-r--r--vendor/twig/twig/doc/templates.rst851
-rw-r--r--vendor/twig/twig/doc/tests/constant.rst22
-rw-r--r--vendor/twig/twig/doc/tests/defined.rst30
-rw-r--r--vendor/twig/twig/doc/tests/divisibleby.rst10
-rw-r--r--vendor/twig/twig/doc/tests/empty.rst11
-rw-r--r--vendor/twig/twig/doc/tests/even.rst10
-rw-r--r--vendor/twig/twig/doc/tests/index.rst15
-rw-r--r--vendor/twig/twig/doc/tests/iterable.rst19
-rw-r--r--vendor/twig/twig/doc/tests/null.rst12
-rw-r--r--vendor/twig/twig/doc/tests/odd.rst10
-rw-r--r--vendor/twig/twig/doc/tests/sameas.rst11
82 files changed, 0 insertions, 6942 deletions
diff --git a/vendor/twig/twig/doc/advanced.rst b/vendor/twig/twig/doc/advanced.rst
deleted file mode 100644
index e1945ebb..00000000
--- a/vendor/twig/twig/doc/advanced.rst
+++ /dev/null
@@ -1,829 +0,0 @@
1Extending Twig
2==============
3
4.. caution::
5
6 This section describes how to extend Twig as of **Twig 1.12**. If you are
7 using an older version, read the :doc:`legacy<advanced_legacy>` chapter
8 instead.
9
10Twig can be extended in many ways; you can add extra tags, filters, tests,
11operators, global variables, and functions. You can even extend the parser
12itself with node visitors.
13
14.. note::
15
16 The first section of this chapter describes how to extend Twig easily. If
17 you want to reuse your changes in different projects or if you want to
18 share them with others, you should then create an extension as described
19 in the following section.
20
21.. caution::
22
23 When extending Twig without creating an extension, Twig won't be able to
24 recompile your templates when the PHP code is updated. To see your changes
25 in real-time, either disable template caching or package your code into an
26 extension (see the next section of this chapter).
27
28Before extending Twig, you must understand the differences between all the
29different possible extension points and when to use them.
30
31First, remember that Twig has two main language constructs:
32
33* ``{{ }}``: used to print the result of an expression evaluation;
34
35* ``{% %}``: used to execute statements.
36
37To understand why Twig exposes so many extension points, let's see how to
38implement a *Lorem ipsum* generator (it needs to know the number of words to
39generate).
40
41You can use a ``lipsum`` *tag*:
42
43.. code-block:: jinja
44
45 {% lipsum 40 %}
46
47That works, but using a tag for ``lipsum`` is not a good idea for at least
48three main reasons:
49
50* ``lipsum`` is not a language construct;
51* The tag outputs something;
52* The tag is not flexible as you cannot use it in an expression:
53
54 .. code-block:: jinja
55
56 {{ 'some text' ~ {% lipsum 40 %} ~ 'some more text' }}
57
58In fact, you rarely need to create tags; and that's good news because tags are
59the most complex extension point of Twig.
60
61Now, let's use a ``lipsum`` *filter*:
62
63.. code-block:: jinja
64
65 {{ 40|lipsum }}
66
67Again, it works, but it looks weird. A filter transforms the passed value to
68something else but here we use the value to indicate the number of words to
69generate (so, ``40`` is an argument of the filter, not the value we want to
70transform).
71
72Next, let's use a ``lipsum`` *function*:
73
74.. code-block:: jinja
75
76 {{ lipsum(40) }}
77
78Here we go. For this specific example, the creation of a function is the
79extension point to use. And you can use it anywhere an expression is accepted:
80
81.. code-block:: jinja
82
83 {{ 'some text' ~ lipsum(40) ~ 'some more text' }}
84
85 {% set lipsum = lipsum(40) %}
86
87Last but not the least, you can also use a *global* object with a method able
88to generate lorem ipsum text:
89
90.. code-block:: jinja
91
92 {{ text.lipsum(40) }}
93
94As a rule of thumb, use functions for frequently used features and global
95objects for everything else.
96
97Keep in mind the following when you want to extend Twig:
98
99========== ========================== ========== =========================
100What? Implementation difficulty? How often? When?
101========== ========================== ========== =========================
102*macro* trivial frequent Content generation
103*global* trivial frequent Helper object
104*function* trivial frequent Content generation
105*filter* trivial frequent Value transformation
106*tag* complex rare DSL language construct
107*test* trivial rare Boolean decision
108*operator* trivial rare Values transformation
109========== ========================== ========== =========================
110
111Globals
112-------
113
114A global variable is like any other template variable, except that it's
115available in all templates and macros::
116
117 $twig = new Twig_Environment($loader);
118 $twig->addGlobal('text', new Text());
119
120You can then use the ``text`` variable anywhere in a template:
121
122.. code-block:: jinja
123
124 {{ text.lipsum(40) }}
125
126Filters
127-------
128
129Creating a filter is as simple as associating a name with a PHP callable::
130
131 // an anonymous function
132 $filter = new Twig_SimpleFilter('rot13', function ($string) {
133 return str_rot13($string);
134 });
135
136 // or a simple PHP function
137 $filter = new Twig_SimpleFilter('rot13', 'str_rot13');
138
139 // or a class method
140 $filter = new Twig_SimpleFilter('rot13', array('SomeClass', 'rot13Filter'));
141
142The first argument passed to the ``Twig_SimpleFilter`` constructor is the name
143of the filter you will use in templates and the second one is the PHP callable
144to associate with it.
145
146Then, add the filter to your Twig environment::
147
148 $twig = new Twig_Environment($loader);
149 $twig->addFilter($filter);
150
151And here is how to use it in a template:
152
153.. code-block:: jinja
154
155 {{ 'Twig'|rot13 }}
156
157 {# will output Gjvt #}
158
159When called by Twig, the PHP callable receives the left side of the filter
160(before the pipe ``|``) as the first argument and the extra arguments passed
161to the filter (within parentheses ``()``) as extra arguments.
162
163For instance, the following code:
164
165.. code-block:: jinja
166
167 {{ 'TWIG'|lower }}
168 {{ now|date('d/m/Y') }}
169
170is compiled to something like the following::
171
172 <?php echo strtolower('TWIG') ?>
173 <?php echo twig_date_format_filter($now, 'd/m/Y') ?>
174
175The ``Twig_SimpleFilter`` class takes an array of options as its last
176argument::
177
178 $filter = new Twig_SimpleFilter('rot13', 'str_rot13', $options);
179
180Environment aware Filters
181~~~~~~~~~~~~~~~~~~~~~~~~~
182
183If you want to access the current environment instance in your filter, set the
184``needs_environment`` option to ``true``; Twig will pass the current
185environment as the first argument to the filter call::
186
187 $filter = new Twig_SimpleFilter('rot13', function (Twig_Environment $env, $string) {
188 // get the current charset for instance
189 $charset = $env->getCharset();
190
191 return str_rot13($string);
192 }, array('needs_environment' => true));
193
194Context aware Filters
195~~~~~~~~~~~~~~~~~~~~~
196
197If you want to access the current context in your filter, set the
198``needs_context`` option to ``true``; Twig will pass the current context as
199the first argument to the filter call (or the second one if
200``needs_environment`` is also set to ``true``)::
201
202 $filter = new Twig_SimpleFilter('rot13', function ($context, $string) {
203 // ...
204 }, array('needs_context' => true));
205
206 $filter = new Twig_SimpleFilter('rot13', function (Twig_Environment $env, $context, $string) {
207 // ...
208 }, array('needs_context' => true, 'needs_environment' => true));
209
210Automatic Escaping
211~~~~~~~~~~~~~~~~~~
212
213If automatic escaping is enabled, the output of the filter may be escaped
214before printing. If your filter acts as an escaper (or explicitly outputs html
215or JavaScript code), you will want the raw output to be printed. In such a
216case, set the ``is_safe`` option::
217
218 $filter = new Twig_SimpleFilter('nl2br', 'nl2br', array('is_safe' => array('html')));
219
220Some filters may need to work on input that is already escaped or safe, for
221example when adding (safe) html tags to originally unsafe output. In such a
222case, set the ``pre_escape`` option to escape the input data before it is run
223through your filter::
224
225 $filter = new Twig_SimpleFilter('somefilter', 'somefilter', array('pre_escape' => 'html', 'is_safe' => array('html')));
226
227Dynamic Filters
228~~~~~~~~~~~~~~~
229
230A filter name containing the special ``*`` character is a dynamic filter as
231the ``*`` can be any string::
232
233 $filter = new Twig_SimpleFilter('*_path', function ($name, $arguments) {
234 // ...
235 });
236
237The following filters will be matched by the above defined dynamic filter:
238
239* ``product_path``
240* ``category_path``
241
242A dynamic filter can define more than one dynamic parts::
243
244 $filter = new Twig_SimpleFilter('*_path_*', function ($name, $suffix, $arguments) {
245 // ...
246 });
247
248The filter will receive all dynamic part values before the normal filter
249arguments, but after the environment and the context. For instance, a call to
250``'foo'|a_path_b()`` will result in the following arguments to be passed to
251the filter: ``('a', 'b', 'foo')``.
252
253Functions
254---------
255
256Functions are defined in the exact same way as filters, but you need to create
257an instance of ``Twig_SimpleFunction``::
258
259 $twig = new Twig_Environment($loader);
260 $function = new Twig_SimpleFunction('function_name', function () {
261 // ...
262 });
263 $twig->addFunction($function);
264
265Functions support the same features as filters, except for the ``pre_escape``
266and ``preserves_safety`` options.
267
268Tests
269-----
270
271Tests are defined in the exact same way as filters and functions, but you need
272to create an instance of ``Twig_SimpleTest``::
273
274 $twig = new Twig_Environment($loader);
275 $test = new Twig_SimpleTest('test_name', function () {
276 // ...
277 });
278 $twig->addTest($test);
279
280Tests allow you to create custom application specific logic for evaluating
281boolean conditions. As a simple, example let's create a Twig test that checks if
282objects are 'red'::
283
284 $twig = new Twig_Environment($loader)
285 $test = new Twig_SimpleTest('red', function ($value) {
286 if (isset($value->color) && $value->color == 'red') {
287 return true;
288 }
289 if (isset($value->paint) && $value->paint == 'red') {
290 return true;
291 }
292 return false;
293 });
294 $twig->addTest($test);
295
296Test functions should always return true/false.
297
298When creating tests you can use the ``node_class`` option to provide custom test
299compilation. This is useful if your test can be compiled into PHP primitives.
300This is used by many of the tests built into Twig::
301
302 $twig = new Twig_Environment($loader)
303 $test = new Twig_SimpleTest(
304 'odd',
305 null,
306 array('node_class' => 'Twig_Node_Expression_Test_Odd'));
307 $twig->addTest($test);
308
309 class Twig_Node_Expression_Test_Odd extends Twig_Node_Expression_Test
310 {
311 public function compile(Twig_Compiler $compiler)
312 {
313 $compiler
314 ->raw('(')
315 ->subcompile($this->getNode('node'))
316 ->raw(' % 2 == 1')
317 ->raw(')')
318 ;
319 }
320 }
321
322The above example, shows how you can create tests that use a node class. The
323node class has access to one sub-node called 'node'. This sub-node contains the
324value that is being tested. When the ``odd`` filter is used in code like:
325
326.. code-block:: jinja
327
328 {% if my_value is odd %}
329
330The ``node`` sub-node will contain an expression of ``my_value``. Node based
331tests also have access to the ``arguments`` node. This node will contain the
332various other arguments that have been provided to your test.
333
334Tags
335----
336
337One of the most exciting feature of a template engine like Twig is the
338possibility to define new language constructs. This is also the most complex
339feature as you need to understand how Twig's internals work.
340
341Let's create a simple ``set`` tag that allows the definition of simple
342variables from within a template. The tag can be used like follows:
343
344.. code-block:: jinja
345
346 {% set name = "value" %}
347
348 {{ name }}
349
350 {# should output value #}
351
352.. note::
353
354 The ``set`` tag is part of the Core extension and as such is always
355 available. The built-in version is slightly more powerful and supports
356 multiple assignments by default (cf. the template designers chapter for
357 more information).
358
359Three steps are needed to define a new tag:
360
361* Defining a Token Parser class (responsible for parsing the template code);
362
363* Defining a Node class (responsible for converting the parsed code to PHP);
364
365* Registering the tag.
366
367Registering a new tag
368~~~~~~~~~~~~~~~~~~~~~
369
370Adding a tag is as simple as calling the ``addTokenParser`` method on the
371``Twig_Environment`` instance::
372
373 $twig = new Twig_Environment($loader);
374 $twig->addTokenParser(new Project_Set_TokenParser());
375
376Defining a Token Parser
377~~~~~~~~~~~~~~~~~~~~~~~
378
379Now, let's see the actual code of this class::
380
381 class Project_Set_TokenParser extends Twig_TokenParser
382 {
383 public function parse(Twig_Token $token)
384 {
385 $parser = $this->parser;
386 $stream = $parser->getStream();
387
388 $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
389 $stream->expect(Twig_Token::OPERATOR_TYPE, '=');
390 $value = $parser->getExpressionParser()->parseExpression();
391 $stream->expect(Twig_Token::BLOCK_END_TYPE);
392
393 return new Project_Set_Node($name, $value, $token->getLine(), $this->getTag());
394 }
395
396 public function getTag()
397 {
398 return 'set';
399 }
400 }
401
402The ``getTag()`` method must return the tag we want to parse, here ``set``.
403
404The ``parse()`` method is invoked whenever the parser encounters a ``set``
405tag. It should return a ``Twig_Node`` instance that represents the node (the
406``Project_Set_Node`` calls creating is explained in the next section).
407
408The parsing process is simplified thanks to a bunch of methods you can call
409from the token stream (``$this->parser->getStream()``):
410
411* ``getCurrent()``: Gets the current token in the stream.
412
413* ``next()``: Moves to the next token in the stream, *but returns the old one*.
414
415* ``test($type)``, ``test($value)`` or ``test($type, $value)``: Determines whether
416 the current token is of a particular type or value (or both). The value may be an
417 array of several possible values.
418
419* ``expect($type[, $value[, $message]])``: If the current token isn't of the given
420 type/value a syntax error is thrown. Otherwise, if the type and value are correct,
421 the token is returned and the stream moves to the next token.
422
423* ``look()``: Looks a the next token without consuming it.
424
425Parsing expressions is done by calling the ``parseExpression()`` like we did for
426the ``set`` tag.
427
428.. tip::
429
430 Reading the existing ``TokenParser`` classes is the best way to learn all
431 the nitty-gritty details of the parsing process.
432
433Defining a Node
434~~~~~~~~~~~~~~~
435
436The ``Project_Set_Node`` class itself is rather simple::
437
438 class Project_Set_Node extends Twig_Node
439 {
440 public function __construct($name, Twig_Node_Expression $value, $line, $tag = null)
441 {
442 parent::__construct(array('value' => $value), array('name' => $name), $line, $tag);
443 }
444
445 public function compile(Twig_Compiler $compiler)
446 {
447 $compiler
448 ->addDebugInfo($this)
449 ->write('$context[\''.$this->getAttribute('name').'\'] = ')
450 ->subcompile($this->getNode('value'))
451 ->raw(";\n")
452 ;
453 }
454 }
455
456The compiler implements a fluid interface and provides methods that helps the
457developer generate beautiful and readable PHP code:
458
459* ``subcompile()``: Compiles a node.
460
461* ``raw()``: Writes the given string as is.
462
463* ``write()``: Writes the given string by adding indentation at the beginning
464 of each line.
465
466* ``string()``: Writes a quoted string.
467
468* ``repr()``: Writes a PHP representation of a given value (see
469 ``Twig_Node_For`` for a usage example).
470
471* ``addDebugInfo()``: Adds the line of the original template file related to
472 the current node as a comment.
473
474* ``indent()``: Indents the generated code (see ``Twig_Node_Block`` for a
475 usage example).
476
477* ``outdent()``: Outdents the generated code (see ``Twig_Node_Block`` for a
478 usage example).
479
480.. _creating_extensions:
481
482Creating an Extension
483---------------------
484
485The main motivation for writing an extension is to move often used code into a
486reusable class like adding support for internationalization. An extension can
487define tags, filters, tests, operators, global variables, functions, and node
488visitors.
489
490Creating an extension also makes for a better separation of code that is
491executed at compilation time and code needed at runtime. As such, it makes
492your code faster.
493
494Most of the time, it is useful to create a single extension for your project,
495to host all the specific tags and filters you want to add to Twig.
496
497.. tip::
498
499 When packaging your code into an extension, Twig is smart enough to
500 recompile your templates whenever you make a change to it (when
501 ``auto_reload`` is enabled).
502
503.. note::
504
505 Before writing your own extensions, have a look at the Twig official
506 extension repository: http://github.com/fabpot/Twig-extensions.
507
508An extension is a class that implements the following interface::
509
510 interface Twig_ExtensionInterface
511 {
512 /**
513 * Initializes the runtime environment.
514 *
515 * This is where you can load some file that contains filter functions for instance.
516 *
517 * @param Twig_Environment $environment The current Twig_Environment instance
518 */
519 function initRuntime(Twig_Environment $environment);
520
521 /**
522 * Returns the token parser instances to add to the existing list.
523 *
524 * @return array An array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances
525 */
526 function getTokenParsers();
527
528 /**
529 * Returns the node visitor instances to add to the existing list.
530 *
531 * @return array An array of Twig_NodeVisitorInterface instances
532 */
533 function getNodeVisitors();
534
535 /**
536 * Returns a list of filters to add to the existing list.
537 *
538 * @return array An array of filters
539 */
540 function getFilters();
541
542 /**
543 * Returns a list of tests to add to the existing list.
544 *
545 * @return array An array of tests
546 */
547 function getTests();
548
549 /**
550 * Returns a list of functions to add to the existing list.
551 *
552 * @return array An array of functions
553 */
554 function getFunctions();
555
556 /**
557 * Returns a list of operators to add to the existing list.
558 *
559 * @return array An array of operators
560 */
561 function getOperators();
562
563 /**
564 * Returns a list of global variables to add to the existing list.
565 *
566 * @return array An array of global variables
567 */
568 function getGlobals();
569
570 /**
571 * Returns the name of the extension.
572 *
573 * @return string The extension name
574 */
575 function getName();
576 }
577
578To keep your extension class clean and lean, it can inherit from the built-in
579``Twig_Extension`` class instead of implementing the whole interface. That
580way, you just need to implement the ``getName()`` method as the
581``Twig_Extension`` provides empty implementations for all other methods.
582
583The ``getName()`` method must return a unique identifier for your extension.
584
585Now, with this information in mind, let's create the most basic extension
586possible::
587
588 class Project_Twig_Extension extends Twig_Extension
589 {
590 public function getName()
591 {
592 return 'project';
593 }
594 }
595
596.. note::
597
598 Of course, this extension does nothing for now. We will customize it in
599 the next sections.
600
601Twig does not care where you save your extension on the filesystem, as all
602extensions must be registered explicitly to be available in your templates.
603
604You can register an extension by using the ``addExtension()`` method on your
605main ``Environment`` object::
606
607 $twig = new Twig_Environment($loader);
608 $twig->addExtension(new Project_Twig_Extension());
609
610Of course, you need to first load the extension file by either using
611``require_once()`` or by using an autoloader (see `spl_autoload_register()`_).
612
613.. tip::
614
615 The bundled extensions are great examples of how extensions work.
616
617Globals
618~~~~~~~
619
620Global variables can be registered in an extension via the ``getGlobals()``
621method::
622
623 class Project_Twig_Extension extends Twig_Extension
624 {
625 public function getGlobals()
626 {
627 return array(
628 'text' => new Text(),
629 );
630 }
631
632 // ...
633 }
634
635Functions
636~~~~~~~~~
637
638Functions can be registered in an extension via the ``getFunctions()``
639method::
640
641 class Project_Twig_Extension extends Twig_Extension
642 {
643 public function getFunctions()
644 {
645 return array(
646 new Twig_SimpleFunction('lipsum', 'generate_lipsum'),
647 );
648 }
649
650 // ...
651 }
652
653Filters
654~~~~~~~
655
656To add a filter to an extension, you need to override the ``getFilters()``
657method. This method must return an array of filters to add to the Twig
658environment::
659
660 class Project_Twig_Extension extends Twig_Extension
661 {
662 public function getFilters()
663 {
664 return array(
665 new Twig_SimpleFilter('rot13', 'str_rot13'),
666 );
667 }
668
669 // ...
670 }
671
672Tags
673~~~~
674
675Adding a tag in an extension can be done by overriding the
676``getTokenParsers()`` method. This method must return an array of tags to add
677to the Twig environment::
678
679 class Project_Twig_Extension extends Twig_Extension
680 {
681 public function getTokenParsers()
682 {
683 return array(new Project_Set_TokenParser());
684 }
685
686 // ...
687 }
688
689In the above code, we have added a single new tag, defined by the
690``Project_Set_TokenParser`` class. The ``Project_Set_TokenParser`` class is
691responsible for parsing the tag and compiling it to PHP.
692
693Operators
694~~~~~~~~~
695
696The ``getOperators()`` methods allows to add new operators. Here is how to add
697``!``, ``||``, and ``&&`` operators::
698
699 class Project_Twig_Extension extends Twig_Extension
700 {
701 public function getOperators()
702 {
703 return array(
704 array(
705 '!' => array('precedence' => 50, 'class' => 'Twig_Node_Expression_Unary_Not'),
706 ),
707 array(
708 '||' => array('precedence' => 10, 'class' => 'Twig_Node_Expression_Binary_Or', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
709 '&&' => array('precedence' => 15, 'class' => 'Twig_Node_Expression_Binary_And', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
710 ),
711 );
712 }
713
714 // ...
715 }
716
717Tests
718~~~~~
719
720The ``getTests()`` methods allows to add new test functions::
721
722 class Project_Twig_Extension extends Twig_Extension
723 {
724 public function getTests()
725 {
726 return array(
727 new Twig_SimpleTest('even', 'twig_test_even'),
728 );
729 }
730
731 // ...
732 }
733
734Overloading
735-----------
736
737To overload an already defined filter, test, operator, global variable, or
738function, define it again **as late as possible**::
739
740 $twig = new Twig_Environment($loader);
741 $twig->addFilter(new Twig_SimpleFilter('date', function ($timestamp, $format = 'F j, Y H:i') {
742 // do something different from the built-in date filter
743 }));
744
745Here, we have overloaded the built-in ``date`` filter with a custom one.
746
747That also works with an extension::
748
749 class MyCoreExtension extends Twig_Extension
750 {
751 public function getFilters()
752 {
753 return array(
754 new Twig_SimpleFilter('date', array($this, 'dateFilter')),
755 );
756 }
757
758 public function dateFilter($timestamp, $format = 'F j, Y H:i')
759 {
760 // do something different from the built-in date filter
761 }
762
763 public function getName()
764 {
765 return 'project';
766 }
767 }
768
769 $twig = new Twig_Environment($loader);
770 $twig->addExtension(new MyCoreExtension());
771
772.. caution::
773
774 Note that overloading the built-in Twig elements is not recommended as it
775 might be confusing.
776
777Testing an Extension
778--------------------
779
780Functional Tests
781~~~~~~~~~~~~~~~~
782
783You can create functional tests for extensions simply by creating the
784following file structure in your test directory::
785
786 Fixtures/
787 filters/
788 foo.test
789 bar.test
790 functions/
791 foo.test
792 bar.test
793 tags/
794 foo.test
795 bar.test
796 IntegrationTest.php
797
798The ``IntegrationTest.php`` file should look like this::
799
800 class Project_Tests_IntegrationTest extends Twig_Test_IntegrationTestCase
801 {
802 public function getExtensions()
803 {
804 return array(
805 new Project_Twig_Extension1(),
806 new Project_Twig_Extension2(),
807 );
808 }
809
810 public function getFixturesDir()
811 {
812 return dirname(__FILE__).'/Fixtures/';
813 }
814 }
815
816Fixtures examples can be found within the Twig repository
817`tests/Twig/Fixtures`_ directory.
818
819Node Tests
820~~~~~~~~~~
821
822Testing the node visitors can be complex, so extend your test cases from
823``Twig_Test_NodeTestCase``. Examples can be found in the Twig repository
824`tests/Twig/Node`_ directory.
825
826.. _`spl_autoload_register()`: http://www.php.net/spl_autoload_register
827.. _`rot13`: http://www.php.net/manual/en/function.str-rot13.php
828.. _`tests/Twig/Fixtures`: https://github.com/fabpot/Twig/tree/master/test/Twig/Tests/Fixtures
829.. _`tests/Twig/Node`: https://github.com/fabpot/Twig/tree/master/test/Twig/Tests/Node
diff --git a/vendor/twig/twig/doc/advanced_legacy.rst b/vendor/twig/twig/doc/advanced_legacy.rst
deleted file mode 100644
index 3d34f932..00000000
--- a/vendor/twig/twig/doc/advanced_legacy.rst
+++ /dev/null
@@ -1,887 +0,0 @@
1Extending Twig
2==============
3
4.. caution::
5
6 This section describes how to extends Twig for versions **older than
7 1.12**. If you are using a newer version, read the :doc:`newer<advanced>`
8 chapter instead.
9
10Twig can be extended in many ways; you can add extra tags, filters, tests,
11operators, global variables, and functions. You can even extend the parser
12itself with node visitors.
13
14.. note::
15
16 The first section of this chapter describes how to extend Twig easily. If
17 you want to reuse your changes in different projects or if you want to
18 share them with others, you should then create an extension as described
19 in the following section.
20
21.. caution::
22
23 When extending Twig by calling methods on the Twig environment instance,
24 Twig won't be able to recompile your templates when the PHP code is
25 updated. To see your changes in real-time, either disable template caching
26 or package your code into an extension (see the next section of this
27 chapter).
28
29Before extending Twig, you must understand the differences between all the
30different possible extension points and when to use them.
31
32First, remember that Twig has two main language constructs:
33
34* ``{{ }}``: used to print the result of an expression evaluation;
35
36* ``{% %}``: used to execute statements.
37
38To understand why Twig exposes so many extension points, let's see how to
39implement a *Lorem ipsum* generator (it needs to know the number of words to
40generate).
41
42You can use a ``lipsum`` *tag*:
43
44.. code-block:: jinja
45
46 {% lipsum 40 %}
47
48That works, but using a tag for ``lipsum`` is not a good idea for at least
49three main reasons:
50
51* ``lipsum`` is not a language construct;
52* The tag outputs something;
53* The tag is not flexible as you cannot use it in an expression:
54
55 .. code-block:: jinja
56
57 {{ 'some text' ~ {% lipsum 40 %} ~ 'some more text' }}
58
59In fact, you rarely need to create tags; and that's good news because tags are
60the most complex extension point of Twig.
61
62Now, let's use a ``lipsum`` *filter*:
63
64.. code-block:: jinja
65
66 {{ 40|lipsum }}
67
68Again, it works, but it looks weird. A filter transforms the passed value to
69something else but here we use the value to indicate the number of words to
70generate (so, ``40`` is an argument of the filter, not the value we want to
71transform).
72
73Next, let's use a ``lipsum`` *function*:
74
75.. code-block:: jinja
76
77 {{ lipsum(40) }}
78
79Here we go. For this specific example, the creation of a function is the
80extension point to use. And you can use it anywhere an expression is accepted:
81
82.. code-block:: jinja
83
84 {{ 'some text' ~ ipsum(40) ~ 'some more text' }}
85
86 {% set ipsum = ipsum(40) %}
87
88Last but not the least, you can also use a *global* object with a method able
89to generate lorem ipsum text:
90
91.. code-block:: jinja
92
93 {{ text.lipsum(40) }}
94
95As a rule of thumb, use functions for frequently used features and global
96objects for everything else.
97
98Keep in mind the following when you want to extend Twig:
99
100========== ========================== ========== =========================
101What? Implementation difficulty? How often? When?
102========== ========================== ========== =========================
103*macro* trivial frequent Content generation
104*global* trivial frequent Helper object
105*function* trivial frequent Content generation
106*filter* trivial frequent Value transformation
107*tag* complex rare DSL language construct
108*test* trivial rare Boolean decision
109*operator* trivial rare Values transformation
110========== ========================== ========== =========================
111
112Globals
113-------
114
115A global variable is like any other template variable, except that it's
116available in all templates and macros::
117
118 $twig = new Twig_Environment($loader);
119 $twig->addGlobal('text', new Text());
120
121You can then use the ``text`` variable anywhere in a template:
122
123.. code-block:: jinja
124
125 {{ text.lipsum(40) }}
126
127Filters
128-------
129
130A filter is a regular PHP function or an object method that takes the left
131side of the filter (before the pipe ``|``) as first argument and the extra
132arguments passed to the filter (within parentheses ``()``) as extra arguments.
133
134Defining a filter is as easy as associating the filter name with a PHP
135callable. For instance, let's say you have the following code in a template:
136
137.. code-block:: jinja
138
139 {{ 'TWIG'|lower }}
140
141When compiling this template to PHP, Twig looks for the PHP callable
142associated with the ``lower`` filter. The ``lower`` filter is a built-in Twig
143filter, and it is simply mapped to the PHP ``strtolower()`` function. After
144compilation, the generated PHP code is roughly equivalent to:
145
146.. code-block:: html+php
147
148 <?php echo strtolower('TWIG') ?>
149
150As you can see, the ``'TWIG'`` string is passed as a first argument to the PHP
151function.
152
153A filter can also take extra arguments like in the following example:
154
155.. code-block:: jinja
156
157 {{ now|date('d/m/Y') }}
158
159In this case, the extra arguments are passed to the function after the main
160argument, and the compiled code is equivalent to:
161
162.. code-block:: html+php
163
164 <?php echo twig_date_format_filter($now, 'd/m/Y') ?>
165
166Let's see how to create a new filter.
167
168In this section, we will create a ``rot13`` filter, which should return the
169`rot13`_ transformation of a string. Here is an example of its usage and the
170expected output:
171
172.. code-block:: jinja
173
174 {{ "Twig"|rot13 }}
175
176 {# should displays Gjvt #}
177
178Adding a filter is as simple as calling the ``addFilter()`` method on the
179``Twig_Environment`` instance::
180
181 $twig = new Twig_Environment($loader);
182 $twig->addFilter('rot13', new Twig_Filter_Function('str_rot13'));
183
184The second argument of ``addFilter()`` is an instance of ``Twig_Filter``.
185Here, we use ``Twig_Filter_Function`` as the filter is a PHP function. The
186first argument passed to the ``Twig_Filter_Function`` constructor is the name
187of the PHP function to call, here ``str_rot13``, a native PHP function.
188
189Let's say I now want to be able to add a prefix before the converted string:
190
191.. code-block:: jinja
192
193 {{ "Twig"|rot13('prefix_') }}
194
195 {# should displays prefix_Gjvt #}
196
197As the PHP ``str_rot13()`` function does not support this requirement, let's
198create a new PHP function::
199
200 function project_compute_rot13($string, $prefix = '')
201 {
202 return $prefix.str_rot13($string);
203 }
204
205As you can see, the ``prefix`` argument of the filter is passed as an extra
206argument to the ``project_compute_rot13()`` function.
207
208Adding this filter is as easy as before::
209
210 $twig->addFilter('rot13', new Twig_Filter_Function('project_compute_rot13'));
211
212For better encapsulation, a filter can also be defined as a static method of a
213class. The ``Twig_Filter_Function`` class can also be used to register such
214static methods as filters::
215
216 $twig->addFilter('rot13', new Twig_Filter_Function('SomeClass::rot13Filter'));
217
218.. tip::
219
220 In an extension, you can also define a filter as a static method of the
221 extension class.
222
223Environment aware Filters
224~~~~~~~~~~~~~~~~~~~~~~~~~
225
226The ``Twig_Filter`` classes take options as their last argument. For instance,
227if you want access to the current environment instance in your filter, set the
228``needs_environment`` option to ``true``::
229
230 $filter = new Twig_Filter_Function('str_rot13', array('needs_environment' => true));
231
232Twig will then pass the current environment as the first argument to the
233filter call::
234
235 function twig_compute_rot13(Twig_Environment $env, $string)
236 {
237 // get the current charset for instance
238 $charset = $env->getCharset();
239
240 return str_rot13($string);
241 }
242
243Automatic Escaping
244~~~~~~~~~~~~~~~~~~
245
246If automatic escaping is enabled, the output of the filter may be escaped
247before printing. If your filter acts as an escaper (or explicitly outputs html
248or javascript code), you will want the raw output to be printed. In such a
249case, set the ``is_safe`` option::
250
251 $filter = new Twig_Filter_Function('nl2br', array('is_safe' => array('html')));
252
253Some filters may need to work on input that is already escaped or safe, for
254example when adding (safe) html tags to originally unsafe output. In such a
255case, set the ``pre_escape`` option to escape the input data before it is run
256through your filter::
257
258 $filter = new Twig_Filter_Function('somefilter', array('pre_escape' => 'html', 'is_safe' => array('html')));
259
260Dynamic Filters
261~~~~~~~~~~~~~~~
262
263.. versionadded:: 1.5
264 Dynamic filters support was added in Twig 1.5.
265
266A filter name containing the special ``*`` character is a dynamic filter as
267the ``*`` can be any string::
268
269 $twig->addFilter('*_path_*', new Twig_Filter_Function('twig_path'));
270
271 function twig_path($name, $arguments)
272 {
273 // ...
274 }
275
276The following filters will be matched by the above defined dynamic filter:
277
278* ``product_path``
279* ``category_path``
280
281A dynamic filter can define more than one dynamic parts::
282
283 $twig->addFilter('*_path_*', new Twig_Filter_Function('twig_path'));
284
285 function twig_path($name, $suffix, $arguments)
286 {
287 // ...
288 }
289
290The filter will receive all dynamic part values before the normal filters
291arguments. For instance, a call to ``'foo'|a_path_b()`` will result in the
292following PHP call: ``twig_path('a', 'b', 'foo')``.
293
294Functions
295---------
296
297A function is a regular PHP function or an object method that can be called from
298templates.
299
300.. code-block:: jinja
301
302 {{ constant("DATE_W3C") }}
303
304When compiling this template to PHP, Twig looks for the PHP callable
305associated with the ``constant`` function. The ``constant`` function is a built-in Twig
306function, and it is simply mapped to the PHP ``constant()`` function. After
307compilation, the generated PHP code is roughly equivalent to:
308
309.. code-block:: html+php
310
311 <?php echo constant('DATE_W3C') ?>
312
313Adding a function is similar to adding a filter. This can be done by calling the
314``addFunction()`` method on the ``Twig_Environment`` instance::
315
316 $twig = new Twig_Environment($loader);
317 $twig->addFunction('functionName', new Twig_Function_Function('someFunction'));
318
319You can also expose extension methods as functions in your templates::
320
321 // $this is an object that implements Twig_ExtensionInterface.
322 $twig = new Twig_Environment($loader);
323 $twig->addFunction('otherFunction', new Twig_Function_Method($this, 'someMethod'));
324
325Functions also support ``needs_environment`` and ``is_safe`` parameters.
326
327Dynamic Functions
328~~~~~~~~~~~~~~~~~
329
330.. versionadded:: 1.5
331 Dynamic functions support was added in Twig 1.5.
332
333A function name containing the special ``*`` character is a dynamic function
334as the ``*`` can be any string::
335
336 $twig->addFunction('*_path', new Twig_Function_Function('twig_path'));
337
338 function twig_path($name, $arguments)
339 {
340 // ...
341 }
342
343The following functions will be matched by the above defined dynamic function:
344
345* ``product_path``
346* ``category_path``
347
348A dynamic function can define more than one dynamic parts::
349
350 $twig->addFilter('*_path_*', new Twig_Filter_Function('twig_path'));
351
352 function twig_path($name, $suffix, $arguments)
353 {
354 // ...
355 }
356
357The function will receive all dynamic part values before the normal functions
358arguments. For instance, a call to ``a_path_b('foo')`` will result in the
359following PHP call: ``twig_path('a', 'b', 'foo')``.
360
361Tags
362----
363
364One of the most exciting feature of a template engine like Twig is the
365possibility to define new language constructs. This is also the most complex
366feature as you need to understand how Twig's internals work.
367
368Let's create a simple ``set`` tag that allows the definition of simple
369variables from within a template. The tag can be used like follows:
370
371.. code-block:: jinja
372
373 {% set name = "value" %}
374
375 {{ name }}
376
377 {# should output value #}
378
379.. note::
380
381 The ``set`` tag is part of the Core extension and as such is always
382 available. The built-in version is slightly more powerful and supports
383 multiple assignments by default (cf. the template designers chapter for
384 more information).
385
386Three steps are needed to define a new tag:
387
388* Defining a Token Parser class (responsible for parsing the template code);
389
390* Defining a Node class (responsible for converting the parsed code to PHP);
391
392* Registering the tag.
393
394Registering a new tag
395~~~~~~~~~~~~~~~~~~~~~
396
397Adding a tag is as simple as calling the ``addTokenParser`` method on the
398``Twig_Environment`` instance::
399
400 $twig = new Twig_Environment($loader);
401 $twig->addTokenParser(new Project_Set_TokenParser());
402
403Defining a Token Parser
404~~~~~~~~~~~~~~~~~~~~~~~
405
406Now, let's see the actual code of this class::
407
408 class Project_Set_TokenParser extends Twig_TokenParser
409 {
410 public function parse(Twig_Token $token)
411 {
412 $lineno = $token->getLine();
413 $name = $this->parser->getStream()->expect(Twig_Token::NAME_TYPE)->getValue();
414 $this->parser->getStream()->expect(Twig_Token::OPERATOR_TYPE, '=');
415 $value = $this->parser->getExpressionParser()->parseExpression();
416
417 $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
418
419 return new Project_Set_Node($name, $value, $lineno, $this->getTag());
420 }
421
422 public function getTag()
423 {
424 return 'set';
425 }
426 }
427
428The ``getTag()`` method must return the tag we want to parse, here ``set``.
429
430The ``parse()`` method is invoked whenever the parser encounters a ``set``
431tag. It should return a ``Twig_Node`` instance that represents the node (the
432``Project_Set_Node`` calls creating is explained in the next section).
433
434The parsing process is simplified thanks to a bunch of methods you can call
435from the token stream (``$this->parser->getStream()``):
436
437* ``getCurrent()``: Gets the current token in the stream.
438
439* ``next()``: Moves to the next token in the stream, *but returns the old one*.
440
441* ``test($type)``, ``test($value)`` or ``test($type, $value)``: Determines whether
442 the current token is of a particular type or value (or both). The value may be an
443 array of several possible values.
444
445* ``expect($type[, $value[, $message]])``: If the current token isn't of the given
446 type/value a syntax error is thrown. Otherwise, if the type and value are correct,
447 the token is returned and the stream moves to the next token.
448
449* ``look()``: Looks a the next token without consuming it.
450
451Parsing expressions is done by calling the ``parseExpression()`` like we did for
452the ``set`` tag.
453
454.. tip::
455
456 Reading the existing ``TokenParser`` classes is the best way to learn all
457 the nitty-gritty details of the parsing process.
458
459Defining a Node
460~~~~~~~~~~~~~~~
461
462The ``Project_Set_Node`` class itself is rather simple::
463
464 class Project_Set_Node extends Twig_Node
465 {
466 public function __construct($name, Twig_Node_Expression $value, $lineno, $tag = null)
467 {
468 parent::__construct(array('value' => $value), array('name' => $name), $lineno, $tag);
469 }
470
471 public function compile(Twig_Compiler $compiler)
472 {
473 $compiler
474 ->addDebugInfo($this)
475 ->write('$context[\''.$this->getAttribute('name').'\'] = ')
476 ->subcompile($this->getNode('value'))
477 ->raw(";\n")
478 ;
479 }
480 }
481
482The compiler implements a fluid interface and provides methods that helps the
483developer generate beautiful and readable PHP code:
484
485* ``subcompile()``: Compiles a node.
486
487* ``raw()``: Writes the given string as is.
488
489* ``write()``: Writes the given string by adding indentation at the beginning
490 of each line.
491
492* ``string()``: Writes a quoted string.
493
494* ``repr()``: Writes a PHP representation of a given value (see
495 ``Twig_Node_For`` for a usage example).
496
497* ``addDebugInfo()``: Adds the line of the original template file related to
498 the current node as a comment.
499
500* ``indent()``: Indents the generated code (see ``Twig_Node_Block`` for a
501 usage example).
502
503* ``outdent()``: Outdents the generated code (see ``Twig_Node_Block`` for a
504 usage example).
505
506.. _creating_extensions:
507
508Creating an Extension
509---------------------
510
511The main motivation for writing an extension is to move often used code into a
512reusable class like adding support for internationalization. An extension can
513define tags, filters, tests, operators, global variables, functions, and node
514visitors.
515
516Creating an extension also makes for a better separation of code that is
517executed at compilation time and code needed at runtime. As such, it makes
518your code faster.
519
520Most of the time, it is useful to create a single extension for your project,
521to host all the specific tags and filters you want to add to Twig.
522
523.. tip::
524
525 When packaging your code into an extension, Twig is smart enough to
526 recompile your templates whenever you make a change to it (when the
527 ``auto_reload`` is enabled).
528
529.. note::
530
531 Before writing your own extensions, have a look at the Twig official
532 extension repository: http://github.com/fabpot/Twig-extensions.
533
534An extension is a class that implements the following interface::
535
536 interface Twig_ExtensionInterface
537 {
538 /**
539 * Initializes the runtime environment.
540 *
541 * This is where you can load some file that contains filter functions for instance.
542 *
543 * @param Twig_Environment $environment The current Twig_Environment instance
544 */
545 function initRuntime(Twig_Environment $environment);
546
547 /**
548 * Returns the token parser instances to add to the existing list.
549 *
550 * @return array An array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances
551 */
552 function getTokenParsers();
553
554 /**
555 * Returns the node visitor instances to add to the existing list.
556 *
557 * @return array An array of Twig_NodeVisitorInterface instances
558 */
559 function getNodeVisitors();
560
561 /**
562 * Returns a list of filters to add to the existing list.
563 *
564 * @return array An array of filters
565 */
566 function getFilters();
567
568 /**
569 * Returns a list of tests to add to the existing list.
570 *
571 * @return array An array of tests
572 */
573 function getTests();
574
575 /**
576 * Returns a list of functions to add to the existing list.
577 *
578 * @return array An array of functions
579 */
580 function getFunctions();
581
582 /**
583 * Returns a list of operators to add to the existing list.
584 *
585 * @return array An array of operators
586 */
587 function getOperators();
588
589 /**
590 * Returns a list of global variables to add to the existing list.
591 *
592 * @return array An array of global variables
593 */
594 function getGlobals();
595
596 /**
597 * Returns the name of the extension.
598 *
599 * @return string The extension name
600 */
601 function getName();
602 }
603
604To keep your extension class clean and lean, it can inherit from the built-in
605``Twig_Extension`` class instead of implementing the whole interface. That
606way, you just need to implement the ``getName()`` method as the
607``Twig_Extension`` provides empty implementations for all other methods.
608
609The ``getName()`` method must return a unique identifier for your extension.
610
611Now, with this information in mind, let's create the most basic extension
612possible::
613
614 class Project_Twig_Extension extends Twig_Extension
615 {
616 public function getName()
617 {
618 return 'project';
619 }
620 }
621
622.. note::
623
624 Of course, this extension does nothing for now. We will customize it in
625 the next sections.
626
627Twig does not care where you save your extension on the filesystem, as all
628extensions must be registered explicitly to be available in your templates.
629
630You can register an extension by using the ``addExtension()`` method on your
631main ``Environment`` object::
632
633 $twig = new Twig_Environment($loader);
634 $twig->addExtension(new Project_Twig_Extension());
635
636Of course, you need to first load the extension file by either using
637``require_once()`` or by using an autoloader (see `spl_autoload_register()`_).
638
639.. tip::
640
641 The bundled extensions are great examples of how extensions work.
642
643Globals
644~~~~~~~
645
646Global variables can be registered in an extension via the ``getGlobals()``
647method::
648
649 class Project_Twig_Extension extends Twig_Extension
650 {
651 public function getGlobals()
652 {
653 return array(
654 'text' => new Text(),
655 );
656 }
657
658 // ...
659 }
660
661Functions
662~~~~~~~~~
663
664Functions can be registered in an extension via the ``getFunctions()``
665method::
666
667 class Project_Twig_Extension extends Twig_Extension
668 {
669 public function getFunctions()
670 {
671 return array(
672 'lipsum' => new Twig_Function_Function('generate_lipsum'),
673 );
674 }
675
676 // ...
677 }
678
679Filters
680~~~~~~~
681
682To add a filter to an extension, you need to override the ``getFilters()``
683method. This method must return an array of filters to add to the Twig
684environment::
685
686 class Project_Twig_Extension extends Twig_Extension
687 {
688 public function getFilters()
689 {
690 return array(
691 'rot13' => new Twig_Filter_Function('str_rot13'),
692 );
693 }
694
695 // ...
696 }
697
698As you can see in the above code, the ``getFilters()`` method returns an array
699where keys are the name of the filters (``rot13``) and the values the
700definition of the filter (``new Twig_Filter_Function('str_rot13')``).
701
702As seen in the previous chapter, you can also define filters as static methods
703on the extension class::
704
705$twig->addFilter('rot13', new Twig_Filter_Function('Project_Twig_Extension::rot13Filter'));
706
707You can also use ``Twig_Filter_Method`` instead of ``Twig_Filter_Function``
708when defining a filter to use a method::
709
710 class Project_Twig_Extension extends Twig_Extension
711 {
712 public function getFilters()
713 {
714 return array(
715 'rot13' => new Twig_Filter_Method($this, 'rot13Filter'),
716 );
717 }
718
719 public function rot13Filter($string)
720 {
721 return str_rot13($string);
722 }
723
724 // ...
725 }
726
727The first argument of the ``Twig_Filter_Method`` constructor is always
728``$this``, the current extension object. The second one is the name of the
729method to call.
730
731Using methods for filters is a great way to package your filter without
732polluting the global namespace. This also gives the developer more flexibility
733at the cost of a small overhead.
734
735Overriding default Filters
736..........................
737
738If some default core filters do not suit your needs, you can easily override
739them by creating your own extension. Just use the same names as the one you
740want to override::
741
742 class MyCoreExtension extends Twig_Extension
743 {
744 public function getFilters()
745 {
746 return array(
747 'date' => new Twig_Filter_Method($this, 'dateFilter'),
748 // ...
749 );
750 }
751
752 public function dateFilter($timestamp, $format = 'F j, Y H:i')
753 {
754 return '...'.twig_date_format_filter($timestamp, $format);
755 }
756
757 public function getName()
758 {
759 return 'project';
760 }
761 }
762
763Here, we override the ``date`` filter with a custom one. Using this extension
764is as simple as registering the ``MyCoreExtension`` extension by calling the
765``addExtension()`` method on the environment instance::
766
767 $twig = new Twig_Environment($loader);
768 $twig->addExtension(new MyCoreExtension());
769
770Tags
771~~~~
772
773Adding a tag in an extension can be done by overriding the
774``getTokenParsers()`` method. This method must return an array of tags to add
775to the Twig environment::
776
777 class Project_Twig_Extension extends Twig_Extension
778 {
779 public function getTokenParsers()
780 {
781 return array(new Project_Set_TokenParser());
782 }
783
784 // ...
785 }
786
787In the above code, we have added a single new tag, defined by the
788``Project_Set_TokenParser`` class. The ``Project_Set_TokenParser`` class is
789responsible for parsing the tag and compiling it to PHP.
790
791Operators
792~~~~~~~~~
793
794The ``getOperators()`` methods allows to add new operators. Here is how to add
795``!``, ``||``, and ``&&`` operators::
796
797 class Project_Twig_Extension extends Twig_Extension
798 {
799 public function getOperators()
800 {
801 return array(
802 array(
803 '!' => array('precedence' => 50, 'class' => 'Twig_Node_Expression_Unary_Not'),
804 ),
805 array(
806 '||' => array('precedence' => 10, 'class' => 'Twig_Node_Expression_Binary_Or', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
807 '&&' => array('precedence' => 15, 'class' => 'Twig_Node_Expression_Binary_And', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
808 ),
809 );
810 }
811
812 // ...
813 }
814
815Tests
816~~~~~
817
818The ``getTests()`` methods allows to add new test functions::
819
820 class Project_Twig_Extension extends Twig_Extension
821 {
822 public function getTests()
823 {
824 return array(
825 'even' => new Twig_Test_Function('twig_test_even'),
826 );
827 }
828
829 // ...
830 }
831
832Testing an Extension
833--------------------
834
835.. versionadded:: 1.10
836 Support for functional tests was added in Twig 1.10.
837
838Functional Tests
839~~~~~~~~~~~~~~~~
840
841You can create functional tests for extensions simply by creating the
842following file structure in your test directory::
843
844 Fixtures/
845 filters/
846 foo.test
847 bar.test
848 functions/
849 foo.test
850 bar.test
851 tags/
852 foo.test
853 bar.test
854 IntegrationTest.php
855
856The ``IntegrationTest.php`` file should look like this::
857
858 class Project_Tests_IntegrationTest extends Twig_Test_IntegrationTestCase
859 {
860 public function getExtensions()
861 {
862 return array(
863 new Project_Twig_Extension1(),
864 new Project_Twig_Extension2(),
865 );
866 }
867
868 public function getFixturesDir()
869 {
870 return dirname(__FILE__).'/Fixtures/';
871 }
872 }
873
874Fixtures examples can be found within the Twig repository
875`tests/Twig/Fixtures`_ directory.
876
877Node Tests
878~~~~~~~~~~
879
880Testing the node visitors can be complex, so extend your test cases from
881``Twig_Test_NodeTestCase``. Examples can be found in the Twig repository
882`tests/Twig/Node`_ directory.
883
884.. _`spl_autoload_register()`: http://www.php.net/spl_autoload_register
885.. _`rot13`: http://www.php.net/manual/en/function.str-rot13.php
886.. _`tests/Twig/Fixtures`: https://github.com/fabpot/Twig/tree/master/test/Twig/Tests/Fixtures
887.. _`tests/Twig/Node`: https://github.com/fabpot/Twig/tree/master/test/Twig/Tests/Node
diff --git a/vendor/twig/twig/doc/api.rst b/vendor/twig/twig/doc/api.rst
deleted file mode 100644
index cbccb0f7..00000000
--- a/vendor/twig/twig/doc/api.rst
+++ /dev/null
@@ -1,529 +0,0 @@
1Twig for Developers
2===================
3
4This chapter describes the API to Twig and not the template language. It will
5be most useful as reference to those implementing the template interface to
6the application and not those who are creating Twig templates.
7
8Basics
9------
10
11Twig uses a central object called the **environment** (of class
12``Twig_Environment``). Instances of this class are used to store the
13configuration and extensions, and are used to load templates from the file
14system or other locations.
15
16Most applications will create one ``Twig_Environment`` object on application
17initialization and use that to load templates. In some cases it's however
18useful to have multiple environments side by side, if different configurations
19are in use.
20
21The simplest way to configure Twig to load templates for your application
22looks roughly like this::
23
24 require_once '/path/to/lib/Twig/Autoloader.php';
25 Twig_Autoloader::register();
26
27 $loader = new Twig_Loader_Filesystem('/path/to/templates');
28 $twig = new Twig_Environment($loader, array(
29 'cache' => '/path/to/compilation_cache',
30 ));
31
32This will create a template environment with the default settings and a loader
33that looks up the templates in the ``/path/to/templates/`` folder. Different
34loaders are available and you can also write your own if you want to load
35templates from a database or other resources.
36
37.. note::
38
39 Notice that the second argument of the environment is an array of options.
40 The ``cache`` option is a compilation cache directory, where Twig caches
41 the compiled templates to avoid the parsing phase for sub-sequent
42 requests. It is very different from the cache you might want to add for
43 the evaluated templates. For such a need, you can use any available PHP
44 cache library.
45
46To load a template from this environment you just have to call the
47``loadTemplate()`` method which then returns a ``Twig_Template`` instance::
48
49 $template = $twig->loadTemplate('index.html');
50
51To render the template with some variables, call the ``render()`` method::
52
53 echo $template->render(array('the' => 'variables', 'go' => 'here'));
54
55.. note::
56
57 The ``display()`` method is a shortcut to output the template directly.
58
59You can also load and render the template in one fell swoop::
60
61 echo $twig->render('index.html', array('the' => 'variables', 'go' => 'here'));
62
63.. _environment_options:
64
65Environment Options
66-------------------
67
68When creating a new ``Twig_Environment`` instance, you can pass an array of
69options as the constructor second argument::
70
71 $twig = new Twig_Environment($loader, array('debug' => true));
72
73The following options are available:
74
75* ``debug``: When set to ``true``, the generated templates have a
76 ``__toString()`` method that you can use to display the generated nodes
77 (default to ``false``).
78
79* ``charset``: The charset used by the templates (default to ``utf-8``).
80
81* ``base_template_class``: The base template class to use for generated
82 templates (default to ``Twig_Template``).
83
84* ``cache``: An absolute path where to store the compiled templates, or
85 ``false`` to disable caching (which is the default).
86
87* ``auto_reload``: When developing with Twig, it's useful to recompile the
88 template whenever the source code changes. If you don't provide a value for
89 the ``auto_reload`` option, it will be determined automatically based on the
90 ``debug`` value.
91
92* ``strict_variables``: If set to ``false``, Twig will silently ignore invalid
93 variables (variables and or attributes/methods that do not exist) and
94 replace them with a ``null`` value. When set to ``true``, Twig throws an
95 exception instead (default to ``false``).
96
97* ``autoescape``: If set to ``true``, auto-escaping will be enabled by default
98 for all templates (default to ``true``). As of Twig 1.8, you can set the
99 escaping strategy to use (``html``, ``js``, ``false`` to disable).
100 As of Twig 1.9, you can set the escaping strategy to use (``css``, ``url``,
101 ``html_attr``, or a PHP callback that takes the template "filename" and must
102 return the escaping strategy to use -- the callback cannot be a function name
103 to avoid collision with built-in escaping strategies).
104
105* ``optimizations``: A flag that indicates which optimizations to apply
106 (default to ``-1`` -- all optimizations are enabled; set it to ``0`` to
107 disable).
108
109Loaders
110-------
111
112Loaders are responsible for loading templates from a resource such as the file
113system.
114
115Compilation Cache
116~~~~~~~~~~~~~~~~~
117
118All template loaders can cache the compiled templates on the filesystem for
119future reuse. It speeds up Twig a lot as templates are only compiled once; and
120the performance boost is even larger if you use a PHP accelerator such as APC.
121See the ``cache`` and ``auto_reload`` options of ``Twig_Environment`` above
122for more information.
123
124Built-in Loaders
125~~~~~~~~~~~~~~~~
126
127Here is a list of the built-in loaders Twig provides:
128
129``Twig_Loader_Filesystem``
130..........................
131
132.. versionadded:: 1.10
133 The ``prependPath()`` and support for namespaces were added in Twig 1.10.
134
135``Twig_Loader_Filesystem`` loads templates from the file system. This loader
136can find templates in folders on the file system and is the preferred way to
137load them::
138
139 $loader = new Twig_Loader_Filesystem($templateDir);
140
141It can also look for templates in an array of directories::
142
143 $loader = new Twig_Loader_Filesystem(array($templateDir1, $templateDir2));
144
145With such a configuration, Twig will first look for templates in
146``$templateDir1`` and if they do not exist, it will fallback to look for them
147in the ``$templateDir2``.
148
149You can add or prepend paths via the ``addPath()`` and ``prependPath()``
150methods::
151
152 $loader->addPath($templateDir3);
153 $loader->prependPath($templateDir4);
154
155The filesystem loader also supports namespaced templates. This allows to group
156your templates under different namespaces which have their own template paths.
157
158When using the ``setPaths()``, ``addPath()``, and ``prependPath()`` methods,
159specify the namespace as the second argument (when not specified, these
160methods act on the "main" namespace)::
161
162 $loader->addPath($templateDir, 'admin');
163
164Namespaced templates can be accessed via the special
165``@namespace_name/template_path`` notation::
166
167 $twig->render('@admin/index.html', array());
168
169``Twig_Loader_String``
170......................
171
172``Twig_Loader_String`` loads templates from strings. It's a dummy loader as
173the template reference is the template source code::
174
175 $loader = new Twig_Loader_String();
176 $twig = new Twig_Environment($loader);
177
178 echo $twig->render('Hello {{ name }}!', array('name' => 'Fabien'));
179
180This loader should only be used for unit testing as it has severe limitations:
181several tags, like ``extends`` or ``include`` do not make sense to use as the
182reference to the template is the template source code itself.
183
184``Twig_Loader_Array``
185.....................
186
187``Twig_Loader_Array`` loads a template from a PHP array. It's passed an array
188of strings bound to template names::
189
190 $loader = new Twig_Loader_Array(array(
191 'index.html' => 'Hello {{ name }}!',
192 ));
193 $twig = new Twig_Environment($loader);
194
195 echo $twig->render('index.html', array('name' => 'Fabien'));
196
197This loader is very useful for unit testing. It can also be used for small
198projects where storing all templates in a single PHP file might make sense.
199
200.. tip::
201
202 When using the ``Array`` or ``String`` loaders with a cache mechanism, you
203 should know that a new cache key is generated each time a template content
204 "changes" (the cache key being the source code of the template). If you
205 don't want to see your cache grows out of control, you need to take care
206 of clearing the old cache file by yourself.
207
208``Twig_Loader_Chain``
209.....................
210
211``Twig_Loader_Chain`` delegates the loading of templates to other loaders::
212
213 $loader1 = new Twig_Loader_Array(array(
214 'base.html' => '{% block content %}{% endblock %}',
215 ));
216 $loader2 = new Twig_Loader_Array(array(
217 'index.html' => '{% extends "base.twig" %}{% block content %}Hello {{ name }}{% endblock %}',
218 'base.html' => 'Will never be loaded',
219 ));
220
221 $loader = new Twig_Loader_Chain(array($loader1, $loader2));
222
223 $twig = new Twig_Environment($loader);
224
225When looking for a template, Twig will try each loader in turn and it will
226return as soon as the template is found. When rendering the ``index.html``
227template from the above example, Twig will load it with ``$loader2`` but the
228``base.html`` template will be loaded from ``$loader1``.
229
230``Twig_Loader_Chain`` accepts any loader that implements
231``Twig_LoaderInterface``.
232
233.. note::
234
235 You can also add loaders via the ``addLoader()`` method.
236
237Create your own Loader
238~~~~~~~~~~~~~~~~~~~~~~
239
240All loaders implement the ``Twig_LoaderInterface``::
241
242 interface Twig_LoaderInterface
243 {
244 /**
245 * Gets the source code of a template, given its name.
246 *
247 * @param string $name string The name of the template to load
248 *
249 * @return string The template source code
250 */
251 function getSource($name);
252
253 /**
254 * Gets the cache key to use for the cache for a given template name.
255 *
256 * @param string $name string The name of the template to load
257 *
258 * @return string The cache key
259 */
260 function getCacheKey($name);
261
262 /**
263 * Returns true if the template is still fresh.
264 *
265 * @param string $name The template name
266 * @param timestamp $time The last modification time of the cached template
267 */
268 function isFresh($name, $time);
269 }
270
271As an example, here is how the built-in ``Twig_Loader_String`` reads::
272
273 class Twig_Loader_String implements Twig_LoaderInterface
274 {
275 public function getSource($name)
276 {
277 return $name;
278 }
279
280 public function getCacheKey($name)
281 {
282 return $name;
283 }
284
285 public function isFresh($name, $time)
286 {
287 return false;
288 }
289 }
290
291The ``isFresh()`` method must return ``true`` if the current cached template
292is still fresh, given the last modification time, or ``false`` otherwise.
293
294.. tip::
295
296 As of Twig 1.11.0, you can also implement ``Twig_ExistsLoaderInterface``
297 to make your loader faster when used with the chain loader.
298
299Using Extensions
300----------------
301
302Twig extensions are packages that add new features to Twig. Using an
303extension is as simple as using the ``addExtension()`` method::
304
305 $twig->addExtension(new Twig_Extension_Sandbox());
306
307Twig comes bundled with the following extensions:
308
309* *Twig_Extension_Core*: Defines all the core features of Twig.
310
311* *Twig_Extension_Escaper*: Adds automatic output-escaping and the possibility
312 to escape/unescape blocks of code.
313
314* *Twig_Extension_Sandbox*: Adds a sandbox mode to the default Twig
315 environment, making it safe to evaluate untrusted code.
316
317* *Twig_Extension_Optimizer*: Optimizes the node tree before compilation.
318
319The core, escaper, and optimizer extensions do not need to be added to the
320Twig environment, as they are registered by default.
321
322Built-in Extensions
323-------------------
324
325This section describes the features added by the built-in extensions.
326
327.. tip::
328
329 Read the chapter about extending Twig to learn how to create your own
330 extensions.
331
332Core Extension
333~~~~~~~~~~~~~~
334
335The ``core`` extension defines all the core features of Twig:
336
337* :doc:`Tags <tags/index>`;
338* :doc:`Filters <filters/index>`;
339* :doc:`Functions <functions/index>`;
340* :doc:`Tests <tests/index>`.
341
342Escaper Extension
343~~~~~~~~~~~~~~~~~
344
345The ``escaper`` extension adds automatic output escaping to Twig. It defines a
346tag, ``autoescape``, and a filter, ``raw``.
347
348When creating the escaper extension, you can switch on or off the global
349output escaping strategy::
350
351 $escaper = new Twig_Extension_Escaper('html');
352 $twig->addExtension($escaper);
353
354If set to ``html``, all variables in templates are escaped (using the ``html``
355escaping strategy), except those using the ``raw`` filter:
356
357.. code-block:: jinja
358
359 {{ article.to_html|raw }}
360
361You can also change the escaping mode locally by using the ``autoescape`` tag
362(see the :doc:`autoescape<tags/autoescape>` doc for the syntax used before
363Twig 1.8):
364
365.. code-block:: jinja
366
367 {% autoescape 'html' %}
368 {{ var }}
369 {{ var|raw }} {# var won't be escaped #}
370 {{ var|escape }} {# var won't be double-escaped #}
371 {% endautoescape %}
372
373.. warning::
374
375 The ``autoescape`` tag has no effect on included files.
376
377The escaping rules are implemented as follows:
378
379* Literals (integers, booleans, arrays, ...) used in the template directly as
380 variables or filter arguments are never automatically escaped:
381
382 .. code-block:: jinja
383
384 {{ "Twig<br />" }} {# won't be escaped #}
385
386 {% set text = "Twig<br />" %}
387 {{ text }} {# will be escaped #}
388
389* Expressions which the result is always a literal or a variable marked safe
390 are never automatically escaped:
391
392 .. code-block:: jinja
393
394 {{ foo ? "Twig<br />" : "<br />Twig" }} {# won't be escaped #}
395
396 {% set text = "Twig<br />" %}
397 {{ foo ? text : "<br />Twig" }} {# will be escaped #}
398
399 {% set text = "Twig<br />" %}
400 {{ foo ? text|raw : "<br />Twig" }} {# won't be escaped #}
401
402 {% set text = "Twig<br />" %}
403 {{ foo ? text|escape : "<br />Twig" }} {# the result of the expression won't be escaped #}
404
405* Escaping is applied before printing, after any other filter is applied:
406
407 .. code-block:: jinja
408
409 {{ var|upper }} {# is equivalent to {{ var|upper|escape }} #}
410
411* The `raw` filter should only be used at the end of the filter chain:
412
413 .. code-block:: jinja
414
415 {{ var|raw|upper }} {# will be escaped #}
416
417 {{ var|upper|raw }} {# won't be escaped #}
418
419* Automatic escaping is not applied if the last filter in the chain is marked
420 safe for the current context (e.g. ``html`` or ``js``). ``escaper`` and
421 ``escaper('html')`` are marked safe for html, ``escaper('js')`` is marked
422 safe for javascript, ``raw`` is marked safe for everything.
423
424 .. code-block:: jinja
425
426 {% autoescape 'js' %}
427 {{ var|escape('html') }} {# will be escaped for html and javascript #}
428 {{ var }} {# will be escaped for javascript #}
429 {{ var|escape('js') }} {# won't be double-escaped #}
430 {% endautoescape %}
431
432.. note::
433
434 Note that autoescaping has some limitations as escaping is applied on
435 expressions after evaluation. For instance, when working with
436 concatenation, ``{{ foo|raw ~ bar }}`` won't give the expected result as
437 escaping is applied on the result of the concatenation, not on the
438 individual variables (so, the ``raw`` filter won't have any effect here).
439
440Sandbox Extension
441~~~~~~~~~~~~~~~~~
442
443The ``sandbox`` extension can be used to evaluate untrusted code. Access to
444unsafe attributes and methods is prohibited. The sandbox security is managed
445by a policy instance. By default, Twig comes with one policy class:
446``Twig_Sandbox_SecurityPolicy``. This class allows you to white-list some
447tags, filters, properties, and methods::
448
449 $tags = array('if');
450 $filters = array('upper');
451 $methods = array(
452 'Article' => array('getTitle', 'getBody'),
453 );
454 $properties = array(
455 'Article' => array('title', 'body'),
456 );
457 $functions = array('range');
458 $policy = new Twig_Sandbox_SecurityPolicy($tags, $filters, $methods, $properties, $functions);
459
460With the previous configuration, the security policy will only allow usage of
461the ``if`` tag, and the ``upper`` filter. Moreover, the templates will only be
462able to call the ``getTitle()`` and ``getBody()`` methods on ``Article``
463objects, and the ``title`` and ``body`` public properties. Everything else
464won't be allowed and will generate a ``Twig_Sandbox_SecurityError`` exception.
465
466The policy object is the first argument of the sandbox constructor::
467
468 $sandbox = new Twig_Extension_Sandbox($policy);
469 $twig->addExtension($sandbox);
470
471By default, the sandbox mode is disabled and should be enabled when including
472untrusted template code by using the ``sandbox`` tag:
473
474.. code-block:: jinja
475
476 {% sandbox %}
477 {% include 'user.html' %}
478 {% endsandbox %}
479
480You can sandbox all templates by passing ``true`` as the second argument of
481the extension constructor::
482
483 $sandbox = new Twig_Extension_Sandbox($policy, true);
484
485Optimizer Extension
486~~~~~~~~~~~~~~~~~~~
487
488The ``optimizer`` extension optimizes the node tree before compilation::
489
490 $twig->addExtension(new Twig_Extension_Optimizer());
491
492By default, all optimizations are turned on. You can select the ones you want
493to enable by passing them to the constructor::
494
495 $optimizer = new Twig_Extension_Optimizer(Twig_NodeVisitor_Optimizer::OPTIMIZE_FOR);
496
497 $twig->addExtension($optimizer);
498
499Twig supports the following optimizations:
500
501* ``Twig_NodeVisitor_Optimizer::OPTIMIZE_ALL``, enables all optimizations
502 (this is the default value).
503* ``Twig_NodeVisitor_Optimizer::OPTIMIZE_NONE``, disables all optimizations.
504 This reduces the compilation time, but it can increase the execution time
505 and the consumed memory.
506* ``Twig_NodeVisitor_Optimizer::OPTIMIZE_FOR``, optimizes the ``for`` tag by
507 removing the ``loop`` variable creation whenever possible.
508* ``Twig_NodeVisitor_Optimizer::OPTIMIZE_RAW_FILTER``, removes the ``raw``
509 filter whenever possible.
510* ``Twig_NodeVisitor_Optimizer::OPTIMIZE_VAR_ACCESS``, simplifies the creation
511 and access of variables in the compiled templates whenever possible.
512
513Exceptions
514----------
515
516Twig can throw exceptions:
517
518* ``Twig_Error``: The base exception for all errors.
519
520* ``Twig_Error_Syntax``: Thrown to tell the user that there is a problem with
521 the template syntax.
522
523* ``Twig_Error_Runtime``: Thrown when an error occurs at runtime (when a filter
524 does not exist for instance).
525
526* ``Twig_Error_Loader``: Thrown when an error occurs during template loading.
527
528* ``Twig_Sandbox_SecurityError``: Thrown when an unallowed tag, filter, or
529 method is called in a sandboxed template.
diff --git a/vendor/twig/twig/doc/coding_standards.rst b/vendor/twig/twig/doc/coding_standards.rst
deleted file mode 100644
index e0aab35e..00000000
--- a/vendor/twig/twig/doc/coding_standards.rst
+++ /dev/null
@@ -1,101 +0,0 @@
1Coding Standards
2================
3
4When writing Twig templates, we recommend you to follow these official coding
5standards:
6
7* Put one (and only one) space after the start of a delimiter (``{{``, ``{%``,
8 and ``{#``) and before the end of a delimiter (``}}``, ``%}``, and ``#}``):
9
10 .. code-block:: jinja
11
12 {{ foo }}
13 {# comment #}
14 {% if foo %}{% endif %}
15
16 When using the whitespace control character, do not put any spaces between
17 it and the delimiter:
18
19 .. code-block:: jinja
20
21 {{- foo -}}
22 {#- comment -#}
23 {%- if foo -%}{%- endif -%}
24
25* Put one (and only one) space before and after the following operators:
26 comparison operators (``==``, ``!=``, ``<``, ``>``, ``>=``, ``<=``), math
27 operators (``+``, ``-``, ``/``, ``*``, ``%``, ``//``, ``**``), logic
28 operators (``not``, ``and``, ``or``), ``~``, ``is``, ``in``, and the ternary
29 operator (``?:``):
30
31 .. code-block:: jinja
32
33 {{ 1 + 2 }}
34 {{ foo ~ bar }}
35 {{ true ? true : false }}
36
37* Put one (and only one) space after the ``:`` sign in hashes and ``,`` in
38 arrays and hashes:
39
40 .. code-block:: jinja
41
42 {{ [1, 2, 3] }}
43 {{ {'foo': 'bar'} }}
44
45* Do not put any spaces after an opening parenthesis and before a closing
46 parenthesis in expressions:
47
48 .. code-block:: jinja
49
50 {{ 1 + (2 * 3) }}
51
52* Do not put any spaces before and after string delimiters:
53
54 .. code-block:: jinja
55
56 {{ 'foo' }}
57 {{ "foo" }}
58
59* Do not put any spaces before and after the following operators: ``|``,
60 ``.``, ``..``, ``[]``:
61
62 .. code-block:: jinja
63
64 {{ foo|upper|lower }}
65 {{ user.name }}
66 {{ user[name] }}
67 {% for i in 1..12 %}{% endfor %}
68
69* Do not put any spaces before and after the parenthesis used for filter and
70 function calls:
71
72 .. code-block:: jinja
73
74 {{ foo|default('foo') }}
75 {{ range(1..10) }}
76
77* Do not put any spaces before and after the opening and the closing of arrays
78 and hashes:
79
80 .. code-block:: jinja
81
82 {{ [1, 2, 3] }}
83 {{ {'foo': 'bar'} }}
84
85* Use lower cased and underscored variable names:
86
87 .. code-block:: jinja
88
89 {% set foo = 'foo' %}
90 {% set foo_bar = 'foo' %}
91
92* Indent your code inside tags (use the same indentation as the one used for
93 the main language of the file):
94
95 .. code-block:: jinja
96
97 {% block foo %}
98 {% if true %}
99 true
100 {% endif %}
101 {% endblock %}
diff --git a/vendor/twig/twig/doc/deprecated.rst b/vendor/twig/twig/doc/deprecated.rst
deleted file mode 100644
index f0a3a0f0..00000000
--- a/vendor/twig/twig/doc/deprecated.rst
+++ /dev/null
@@ -1,98 +0,0 @@
1Deprecated Features
2===================
3
4This document lists all deprecated features in Twig. Deprecated features are
5kept for backward compatibility and removed in the next major release (a
6feature that was deprecated in Twig 1.x is removed in Twig 2.0).
7
8Token Parsers
9-------------
10
11* As of Twig 1.x, the token parser broker sub-system is deprecated. The
12 following class and interface will be removed in 2.0:
13
14 * ``Twig_TokenParserBrokerInterface``
15 * ``Twig_TokenParserBroker``
16
17Extensions
18----------
19
20* As of Twig 1.x, the ability to remove an extension is deprecated and the
21 ``Twig_Environment::removeExtension()`` method will be removed in 2.0.
22
23PEAR
24----
25
26PEAR support will be discontinued in Twig 2.0, and no PEAR packages will be
27provided. Use Composer instead.
28
29Filters
30-------
31
32* As of Twig 1.x, use ``Twig_SimpleFilter`` to add a filter. The following
33 classes and interfaces will be removed in 2.0:
34
35 * ``Twig_FilterInterface``
36 * ``Twig_FilterCallableInterface``
37 * ``Twig_Filter``
38 * ``Twig_Filter_Function``
39 * ``Twig_Filter_Method``
40 * ``Twig_Filter_Node``
41
42* As of Twig 2.x, the ``Twig_SimpleFilter`` class is deprecated and will be
43 removed in Twig 3.x (use ``Twig_Filter`` instead). In Twig 2.x,
44 ``Twig_SimpleFilter`` is just an alias for ``Twig_Filter``.
45
46Functions
47---------
48
49* As of Twig 1.x, use ``Twig_SimpleFunction`` to add a function. The following
50 classes and interfaces will be removed in 2.0:
51
52 * ``Twig_FunctionInterface``
53 * ``Twig_FunctionCallableInterface``
54 * ``Twig_Function``
55 * ``Twig_Function_Function``
56 * ``Twig_Function_Method``
57 * ``Twig_Function_Node``
58
59* As of Twig 2.x, the ``Twig_SimpleFunction`` class is deprecated and will be
60 removed in Twig 3.x (use ``Twig_Function`` instead). In Twig 2.x,
61 ``Twig_SimpleFunction`` is just an alias for ``Twig_Function``.
62
63Tests
64-----
65
66* As of Twig 1.x, use ``Twig_SimpleTest`` to add a test. The following classes
67 and interfaces will be removed in 2.0:
68
69 * ``Twig_TestInterface``
70 * ``Twig_TestCallableInterface``
71 * ``Twig_Test``
72 * ``Twig_Test_Function``
73 * ``Twig_Test_Method``
74 * ``Twig_Test_Node``
75
76* As of Twig 2.x, the ``Twig_SimpleTest`` class is deprecated and will be
77 removed in Twig 3.x (use ``Twig_Test`` instead). In Twig 2.x,
78 ``Twig_SimpleTest`` is just an alias for ``Twig_Test``.
79
80Interfaces
81----------
82
83* As of Twig 2.x, the following interfaces are deprecated and empty (they will
84 be removed in Twig 3.0):
85
86* ``Twig_CompilerInterface`` (use ``Twig_Compiler`` instead)
87* ``Twig_LexerInterface`` (use ``Twig_Lexer`` instead)
88* ``Twig_NodeInterface`` (use ``Twig_Node`` instead)
89* ``Twig_ParserInterface`` (use ``Twig_Parser`` instead)
90* ``Twig_ExistsLoaderInterface`` (merged with ``Twig_LoaderInterface``)
91* ``Twig_TemplateInterface`` (use ``Twig_Template`` instead)
92
93Globals
94-------
95
96* As of Twig 2.x, the ability to register a global variable after the runtime
97 or the extensions have been initialized is not possible anymore (but
98 changing the value of an already registered global is possible).
diff --git a/vendor/twig/twig/doc/filters/abs.rst b/vendor/twig/twig/doc/filters/abs.rst
deleted file mode 100644
index 3a82f62e..00000000
--- a/vendor/twig/twig/doc/filters/abs.rst
+++ /dev/null
@@ -1,18 +0,0 @@
1``abs``
2=======
3
4The ``abs`` filter returns the absolute value.
5
6.. code-block:: jinja
7
8 {# number = -5 #}
9
10 {{ number|abs }}
11
12 {# outputs 5 #}
13
14.. note::
15
16 Internally, Twig uses the PHP `abs`_ function.
17
18.. _`abs`: http://php.net/abs
diff --git a/vendor/twig/twig/doc/filters/batch.rst b/vendor/twig/twig/doc/filters/batch.rst
deleted file mode 100644
index 4366b57b..00000000
--- a/vendor/twig/twig/doc/filters/batch.rst
+++ /dev/null
@@ -1,45 +0,0 @@
1``batch``
2=========
3
4.. versionadded:: 1.12.3
5 The batch filter was added in Twig 1.12.3.
6
7The ``batch`` filter "batches" items by returning a list of lists with the
8given number of items. If you provide a second parameter, it is used to fill
9missing items:
10
11.. code-block:: jinja
12
13 {% set items = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] %}
14
15 <table>
16 {% for row in items|batch(3, 'No item') %}
17 <tr>
18 {% for column in row %}
19 <td>{{ column }}</td>
20 {% endfor %}
21 </tr>
22 {% endfor %}
23 </table>
24
25The above example will be rendered as:
26
27.. code-block:: jinja
28
29 <table>
30 <tr>
31 <td>a</td>
32 <td>b</td>
33 <td>c</td>
34 </tr>
35 <tr>
36 <td>d</td>
37 <td>e</td>
38 <td>f</td>
39 </tr>
40 <tr>
41 <td>g</td>
42 <td>No item</td>
43 <td>No item</td>
44 </tr>
45 </table>
diff --git a/vendor/twig/twig/doc/filters/capitalize.rst b/vendor/twig/twig/doc/filters/capitalize.rst
deleted file mode 100644
index 10546a1f..00000000
--- a/vendor/twig/twig/doc/filters/capitalize.rst
+++ /dev/null
@@ -1,11 +0,0 @@
1``capitalize``
2==============
3
4The ``capitalize`` filter capitalizes a value. The first character will be
5uppercase, all others lowercase:
6
7.. code-block:: jinja
8
9 {{ 'my first car'|capitalize }}
10
11 {# outputs 'My first car' #}
diff --git a/vendor/twig/twig/doc/filters/convert_encoding.rst b/vendor/twig/twig/doc/filters/convert_encoding.rst
deleted file mode 100644
index 1b0eb60c..00000000
--- a/vendor/twig/twig/doc/filters/convert_encoding.rst
+++ /dev/null
@@ -1,28 +0,0 @@
1``convert_encoding``
2====================
3
4.. versionadded:: 1.4
5 The ``convert_encoding`` filter was added in Twig 1.4.
6
7The ``convert_encoding`` filter converts a string from one encoding to
8another. The first argument is the expected output charset and the second one
9is the input charset:
10
11.. code-block:: jinja
12
13 {{ data|convert_encoding('UTF-8', 'iso-2022-jp') }}
14
15.. note::
16
17 This filter relies on the `iconv`_ or `mbstring`_ extension, so one of
18 them must be installed. In case both are installed, `mbstring`_ is used by
19 default (Twig before 1.8.1 uses `iconv`_ by default).
20
21Arguments
22---------
23
24 * ``from``: The input charset
25 * ``to``: The output charset
26
27.. _`iconv`: http://php.net/iconv
28.. _`mbstring`: http://php.net/mbstring
diff --git a/vendor/twig/twig/doc/filters/date.rst b/vendor/twig/twig/doc/filters/date.rst
deleted file mode 100644
index 8e2f31fa..00000000
--- a/vendor/twig/twig/doc/filters/date.rst
+++ /dev/null
@@ -1,88 +0,0 @@
1``date``
2========
3
4.. versionadded:: 1.1
5 The timezone support has been added in Twig 1.1.
6
7.. versionadded:: 1.5
8 The default date format support has been added in Twig 1.5.
9
10.. versionadded:: 1.6.1
11 The default timezone support has been added in Twig 1.6.1.
12
13.. versionadded:: 1.11.0
14 The introduction of the false value for the timezone was introduced in Twig 1.11.0
15
16The ``date`` filter formats a date to a given format:
17
18.. code-block:: jinja
19
20 {{ post.published_at|date("m/d/Y") }}
21
22The ``date`` filter accepts strings (it must be in a format supported by the
23`strtotime`_ function), `DateTime`_ instances, or `DateInterval`_ instances. For
24instance, to display the current date, filter the word "now":
25
26.. code-block:: jinja
27
28 {{ "now"|date("m/d/Y") }}
29
30To escape words and characters in the date format use ``\\`` in front of each
31character:
32
33.. code-block:: jinja
34
35 {{ post.published_at|date("F jS \\a\\t g:ia") }}
36
37If the value passed to the ``date`` filter is ``null``, it will return the
38current date by default. If an empty string is desired instead of the current
39date, use a ternary operator:
40
41.. code-block:: jinja
42
43 {{ post.published_at is empty ? "" : post.published_at|date("m/d/Y") }}
44
45If no format is provided, Twig will use the default one: ``F j, Y H:i``. This
46default can be easily changed by calling the ``setDateFormat()`` method on the
47``core`` extension instance. The first argument is the default format for
48dates and the second one is the default format for date intervals:
49
50.. code-block:: php
51
52 $twig = new Twig_Environment($loader);
53 $twig->getExtension('core')->setDateFormat('d/m/Y', '%d days');
54
55Timezone
56--------
57
58By default, the date is displayed by applying the default timezone (the one
59specified in php.ini or declared in Twig -- see below), but you can override
60it by explicitly specifying a timezone:
61
62.. code-block:: jinja
63
64 {{ post.published_at|date("m/d/Y", "Europe/Paris") }}
65
66If the date is already a DateTime object, and if you want to keep its current
67timezone, pass ``false`` as the timezone value:
68
69.. code-block:: jinja
70
71 {{ post.published_at|date("m/d/Y", false) }}
72
73The default timezone can also be set globally by calling ``setTimezone()``:
74
75.. code-block:: php
76
77 $twig = new Twig_Environment($loader);
78 $twig->getExtension('core')->setTimezone('Europe/Paris');
79
80Arguments
81---------
82
83 * ``format``: The date format
84 * ``timezone``: The date timezone
85
86.. _`strtotime`: http://www.php.net/strtotime
87.. _`DateTime`: http://www.php.net/DateTime
88.. _`DateInterval`: http://www.php.net/DateInterval
diff --git a/vendor/twig/twig/doc/filters/date_modify.rst b/vendor/twig/twig/doc/filters/date_modify.rst
deleted file mode 100644
index 6a5c73d6..00000000
--- a/vendor/twig/twig/doc/filters/date_modify.rst
+++ /dev/null
@@ -1,23 +0,0 @@
1``date_modify``
2===============
3
4.. versionadded:: 1.9.0
5 The date_modify filter has been added in Twig 1.9.0.
6
7The ``date_modify`` filter modifies a date with a given modifier string:
8
9.. code-block:: jinja
10
11 {{ post.published_at|date_modify("+1 day")|date("m/d/Y") }}
12
13The ``date_modify`` filter accepts strings (it must be in a format supported
14by the `strtotime`_ function) or `DateTime`_ instances. You can easily combine
15it with the :doc:`date<date>` filter for formatting.
16
17Arguments
18---------
19
20 * ``modifier``: The modifier
21
22.. _`strtotime`: http://www.php.net/strtotime
23.. _`DateTime`: http://www.php.net/DateTime
diff --git a/vendor/twig/twig/doc/filters/default.rst b/vendor/twig/twig/doc/filters/default.rst
deleted file mode 100644
index 46ed9636..00000000
--- a/vendor/twig/twig/doc/filters/default.rst
+++ /dev/null
@@ -1,33 +0,0 @@
1``default``
2===========
3
4The ``default`` filter returns the passed default value if the value is
5undefined or empty, otherwise the value of the variable:
6
7.. code-block:: jinja
8
9 {{ var|default('var is not defined') }}
10
11 {{ var.foo|default('foo item on var is not defined') }}
12
13 {{ var['foo']|default('foo item on var is not defined') }}
14
15 {{ ''|default('passed var is empty') }}
16
17When using the ``default`` filter on an expression that uses variables in some
18method calls, be sure to use the ``default`` filter whenever a variable can be
19undefined:
20
21.. code-block:: jinja
22
23 {{ var.method(foo|default('foo'))|default('foo') }}
24
25.. note::
26
27 Read the documentation for the :doc:`defined<../tests/defined>` and
28 :doc:`empty<../tests/empty>` tests to learn more about their semantics.
29
30Arguments
31---------
32
33 * ``default``: The default value
diff --git a/vendor/twig/twig/doc/filters/escape.rst b/vendor/twig/twig/doc/filters/escape.rst
deleted file mode 100644
index 5ade7d74..00000000
--- a/vendor/twig/twig/doc/filters/escape.rst
+++ /dev/null
@@ -1,93 +0,0 @@
1``escape``
2==========
3
4.. versionadded:: 1.9.0
5 The ``css``, ``url``, and ``html_attr`` strategies were added in Twig
6 1.9.0.
7
8The ``escape`` filter escapes a string for safe insertion into the final
9output. It supports different escaping strategies depending on the template
10context.
11
12By default, it uses the HTML escaping strategy:
13
14.. code-block:: jinja
15
16 {{ user.username|escape }}
17
18For convenience, the ``e`` filter is defined as an alias:
19
20.. code-block:: jinja
21
22 {{ user.username|e }}
23
24The ``escape`` filter can also be used in other contexts than HTML thanks to
25an optional argument which defines the escaping strategy to use:
26
27.. code-block:: jinja
28
29 {{ user.username|e }}
30 {# is equivalent to #}
31 {{ user.username|e('html') }}
32
33And here is how to escape variables included in JavaScript code:
34
35.. code-block:: jinja
36
37 {{ user.username|escape('js') }}
38 {{ user.username|e('js') }}
39
40The ``escape`` filter supports the following escaping strategies:
41
42* ``html``: escapes a string for the **HTML body** context.
43
44* ``js``: escapes a string for the **JavaScript context**.
45
46* ``css``: escapes a string for the **CSS context**. CSS escaping can be
47 applied to any string being inserted into CSS and escapes everything except
48 alphanumerics.
49
50* ``url``: escapes a string for the **URI or parameter contexts**. This should
51 not be used to escape an entire URI; only a subcomponent being inserted.
52
53* ``html_attr``: escapes a string for the **HTML attribute** context.
54
55.. note::
56
57 Internally, ``escape`` uses the PHP native `htmlspecialchars`_ function
58 for the HTML escaping strategy.
59
60.. caution::
61
62 When using automatic escaping, Twig tries to not double-escape a variable
63 when the automatic escaping strategy is the same as the one applied by the
64 escape filter; but that does not work when using a variable as the
65 escaping strategy:
66
67 .. code-block:: jinja
68
69 {% set strategy = 'html' %}
70
71 {% autoescape 'html' %}
72 {{ var|escape('html') }} {# won't be double-escaped #}
73 {{ var|escape(strategy) }} {# will be double-escaped #}
74 {% endautoescape %}
75
76 When using a variable as the escaping strategy, you should disable
77 automatic escaping:
78
79 .. code-block:: jinja
80
81 {% set strategy = 'html' %}
82
83 {% autoescape 'html' %}
84 {{ var|escape(strategy)|raw }} {# won't be double-escaped #}
85 {% endautoescape %}
86
87Arguments
88---------
89
90 * ``strategy``: The escaping strategy
91 * ``charset``: The string charset
92
93.. _`htmlspecialchars`: http://php.net/htmlspecialchars
diff --git a/vendor/twig/twig/doc/filters/first.rst b/vendor/twig/twig/doc/filters/first.rst
deleted file mode 100644
index 4295e833..00000000
--- a/vendor/twig/twig/doc/filters/first.rst
+++ /dev/null
@@ -1,25 +0,0 @@
1``first``
2=========
3
4.. versionadded:: 1.12.2
5 The first filter was added in Twig 1.12.2.
6
7The ``first`` filter returns the first "element" of a sequence, a mapping, or
8a string:
9
10.. code-block:: jinja
11
12 {{ [1, 2, 3, 4]|first }}
13 {# outputs 1 #}
14
15 {{ { a: 1, b: 2, c: 3, d: 4 }|first }}
16 {# outputs 1 #}
17
18 {{ '1234'|first }}
19 {# outputs 1 #}
20
21.. note::
22
23 It also works with objects implementing the `Traversable`_ interface.
24
25.. _`Traversable`: http://php.net/manual/en/class.traversable.php
diff --git a/vendor/twig/twig/doc/filters/format.rst b/vendor/twig/twig/doc/filters/format.rst
deleted file mode 100644
index fe55a09e..00000000
--- a/vendor/twig/twig/doc/filters/format.rst
+++ /dev/null
@@ -1,16 +0,0 @@
1``format``
2==========
3
4The ``format`` filter formats a given string by replacing the placeholders
5(placeholders follows the `sprintf`_ notation):
6
7.. code-block:: jinja
8
9 {{ "I like %s and %s."|format(foo, "bar") }}
10
11 {# returns I like foo and bar
12 if the foo parameter equals to the foo string. #}
13
14.. _`sprintf`: http://www.php.net/sprintf
15
16.. seealso:: :doc:`replace<replace>`
diff --git a/vendor/twig/twig/doc/filters/index.rst b/vendor/twig/twig/doc/filters/index.rst
deleted file mode 100644
index b0c6b38d..00000000
--- a/vendor/twig/twig/doc/filters/index.rst
+++ /dev/null
@@ -1,36 +0,0 @@
1Filters
2=======
3
4.. toctree::
5 :maxdepth: 1
6
7 abs
8 batch
9 capitalize
10 convert_encoding
11 date
12 date_modify
13 default
14 escape
15 first
16 format
17 join
18 json_encode
19 keys
20 last
21 length
22 lower
23 nl2br
24 number_format
25 merge
26 upper
27 raw
28 replace
29 reverse
30 slice
31 sort
32 split
33 striptags
34 title
35 trim
36 url_encode
diff --git a/vendor/twig/twig/doc/filters/join.rst b/vendor/twig/twig/doc/filters/join.rst
deleted file mode 100644
index f4952421..00000000
--- a/vendor/twig/twig/doc/filters/join.rst
+++ /dev/null
@@ -1,23 +0,0 @@
1``join``
2========
3
4The ``join`` filter returns a string which is the concatenation of the items
5of a sequence:
6
7.. code-block:: jinja
8
9 {{ [1, 2, 3]|join }}
10 {# returns 123 #}
11
12The separator between elements is an empty string per default, but you can
13define it with the optional first parameter:
14
15.. code-block:: jinja
16
17 {{ [1, 2, 3]|join('|') }}
18 {# returns 1|2|3 #}
19
20Arguments
21---------
22
23 * ``glue``: The separator
diff --git a/vendor/twig/twig/doc/filters/json_encode.rst b/vendor/twig/twig/doc/filters/json_encode.rst
deleted file mode 100644
index a33fef1b..00000000
--- a/vendor/twig/twig/doc/filters/json_encode.rst
+++ /dev/null
@@ -1,21 +0,0 @@
1``json_encode``
2===============
3
4The ``json_encode`` filter returns the JSON representation of a string:
5
6.. code-block:: jinja
7
8 {{ data|json_encode() }}
9
10.. note::
11
12 Internally, Twig uses the PHP `json_encode`_ function.
13
14Arguments
15---------
16
17 * ``options``: A bitmask of `json_encode options`_ (``{{
18 data|json_encode(constant(JSON_PRETTY_PRINT)) }}``)
19
20.. _`json_encode`: http://php.net/json_encode
21.. _`json_encode options`: http://www.php.net/manual/en/json.constants.php
diff --git a/vendor/twig/twig/doc/filters/keys.rst b/vendor/twig/twig/doc/filters/keys.rst
deleted file mode 100644
index e4f090c6..00000000
--- a/vendor/twig/twig/doc/filters/keys.rst
+++ /dev/null
@@ -1,11 +0,0 @@
1``keys``
2========
3
4The ``keys`` filter returns the keys of an array. It is useful when you want to
5iterate over the keys of an array:
6
7.. code-block:: jinja
8
9 {% for key in array|keys %}
10 ...
11 {% endfor %}
diff --git a/vendor/twig/twig/doc/filters/last.rst b/vendor/twig/twig/doc/filters/last.rst
deleted file mode 100644
index 723c0b57..00000000
--- a/vendor/twig/twig/doc/filters/last.rst
+++ /dev/null
@@ -1,25 +0,0 @@
1``last``
2========
3
4.. versionadded:: 1.12.2
5 The last filter was added in Twig 1.12.2.
6
7The ``last`` filter returns the last "element" of a sequence, a mapping, or
8a string:
9
10.. code-block:: jinja
11
12 {{ [1, 2, 3, 4]|last }}
13 {# outputs 4 #}
14
15 {{ { a: 1, b: 2, c: 3, d: 4 }|last }}
16 {# outputs 4 #}
17
18 {{ '1234'|last }}
19 {# outputs 4 #}
20
21.. note::
22
23 It also works with objects implementing the `Traversable`_ interface.
24
25.. _`Traversable`: http://php.net/manual/en/class.traversable.php
diff --git a/vendor/twig/twig/doc/filters/length.rst b/vendor/twig/twig/doc/filters/length.rst
deleted file mode 100644
index f79b9bdf..00000000
--- a/vendor/twig/twig/doc/filters/length.rst
+++ /dev/null
@@ -1,12 +0,0 @@
1``length``
2==========
3
4The ``length`` filters returns the number of items of a sequence or mapping, or
5the length of a string:
6
7.. code-block:: jinja
8
9 {% if users|length > 10 %}
10 ...
11 {% endif %}
12
diff --git a/vendor/twig/twig/doc/filters/lower.rst b/vendor/twig/twig/doc/filters/lower.rst
deleted file mode 100644
index ef9faa90..00000000
--- a/vendor/twig/twig/doc/filters/lower.rst
+++ /dev/null
@@ -1,10 +0,0 @@
1``lower``
2=========
3
4The ``lower`` filter converts a value to lowercase:
5
6.. code-block:: jinja
7
8 {{ 'WELCOME'|lower }}
9
10 {# outputs 'welcome' #}
diff --git a/vendor/twig/twig/doc/filters/merge.rst b/vendor/twig/twig/doc/filters/merge.rst
deleted file mode 100644
index 05a2ae7d..00000000
--- a/vendor/twig/twig/doc/filters/merge.rst
+++ /dev/null
@@ -1,41 +0,0 @@
1``merge``
2=========
3
4The ``merge`` filter merges an array with another array:
5
6.. code-block:: jinja
7
8 {% set values = [1, 2] %}
9
10 {% set values = values|merge(['apple', 'orange']) %}
11
12 {# values now contains [1, 2, 'apple', 'orange'] #}
13
14New values are added at the end of the existing ones.
15
16The ``merge`` filter also works on hashes:
17
18.. code-block:: jinja
19
20 {% set items = { 'apple': 'fruit', 'orange': 'fruit', 'peugeot': 'unknown' } %}
21
22 {% set items = items|merge({ 'peugeot': 'car', 'renault': 'car' }) %}
23
24 {# items now contains { 'apple': 'fruit', 'orange': 'fruit', 'peugeot': 'car', 'renault': 'car' } #}
25
26For hashes, the merging process occurs on the keys: if the key does not
27already exist, it is added but if the key already exists, its value is
28overridden.
29
30.. tip::
31
32 If you want to ensure that some values are defined in an array (by given
33 default values), reverse the two elements in the call:
34
35 .. code-block:: jinja
36
37 {% set items = { 'apple': 'fruit', 'orange': 'fruit' } %}
38
39 {% set items = { 'apple': 'unknown' }|merge(items) %}
40
41 {# items now contains { 'apple': 'fruit', 'orange': 'fruit' } #}
diff --git a/vendor/twig/twig/doc/filters/nl2br.rst b/vendor/twig/twig/doc/filters/nl2br.rst
deleted file mode 100644
index 694c6724..00000000
--- a/vendor/twig/twig/doc/filters/nl2br.rst
+++ /dev/null
@@ -1,22 +0,0 @@
1``nl2br``
2=========
3
4.. versionadded:: 1.5
5 The nl2br filter was added in Twig 1.5.
6
7The ``nl2br`` filter inserts HTML line breaks before all newlines in a string:
8
9.. code-block:: jinja
10
11 {{ "I like Twig.\nYou will like it too."|nl2br }}
12 {# outputs
13
14 I like Twig.<br />
15 You will like it too.
16
17 #}
18
19.. note::
20
21 The ``nl2br`` filter pre-escapes the input before applying the
22 transformation.
diff --git a/vendor/twig/twig/doc/filters/number_format.rst b/vendor/twig/twig/doc/filters/number_format.rst
deleted file mode 100644
index fedacd9d..00000000
--- a/vendor/twig/twig/doc/filters/number_format.rst
+++ /dev/null
@@ -1,45 +0,0 @@
1``number_format``
2=================
3
4.. versionadded:: 1.5
5 The number_format filter was added in Twig 1.5
6
7The ``number_format`` filter formats numbers. It is a wrapper around PHP's
8`number_format`_ function:
9
10.. code-block:: jinja
11
12 {{ 200.35|number_format }}
13
14You can control the number of decimal places, decimal point, and thousands
15separator using the additional arguments:
16
17.. code-block:: jinja
18
19 {{ 9800.333|number_format(2, '.', ',') }}
20
21If no formatting options are provided then Twig will use the default formatting
22options of:
23
24- 0 decimal places.
25- ``.`` as the decimal point.
26- ``,`` as the thousands separator.
27
28These defaults can be easily changed through the core extension:
29
30.. code-block:: php
31
32 $twig = new Twig_Environment($loader);
33 $twig->getExtension('core')->setNumberFormat(3, '.', ',');
34
35The defaults set for ``number_format`` can be over-ridden upon each call using the
36additional parameters.
37
38Arguments
39---------
40
41 * ``decimal``: The number of decimal points to display
42 * ``decimal_point``: The character(s) to use for the decimal point
43 * ``decimal_sep``: The character(s) to use for the thousands separator
44
45.. _`number_format`: http://php.net/number_format
diff --git a/vendor/twig/twig/doc/filters/raw.rst b/vendor/twig/twig/doc/filters/raw.rst
deleted file mode 100644
index 434dd246..00000000
--- a/vendor/twig/twig/doc/filters/raw.rst
+++ /dev/null
@@ -1,12 +0,0 @@
1``raw``
2=======
3
4The ``raw`` filter marks the value as being "safe", which means that in an
5environment with automatic escaping enabled this variable will not be escaped
6if ``raw`` is the last filter applied to it:
7
8.. code-block:: jinja
9
10 {% autoescape true %}
11 {{ var|raw }} {# var won't be escaped #}
12 {% endautoescape %}
diff --git a/vendor/twig/twig/doc/filters/replace.rst b/vendor/twig/twig/doc/filters/replace.rst
deleted file mode 100644
index e961f23d..00000000
--- a/vendor/twig/twig/doc/filters/replace.rst
+++ /dev/null
@@ -1,19 +0,0 @@
1``replace``
2===========
3
4The ``replace`` filter formats a given string by replacing the placeholders
5(placeholders are free-form):
6
7.. code-block:: jinja
8
9 {{ "I like %this% and %that%."|replace({'%this%': foo, '%that%': "bar"}) }}
10
11 {# returns I like foo and bar
12 if the foo parameter equals to the foo string. #}
13
14Arguments
15---------
16
17 * ``replace_pairs``: The placeholder values
18
19.. seealso:: :doc:`format<format>`
diff --git a/vendor/twig/twig/doc/filters/reverse.rst b/vendor/twig/twig/doc/filters/reverse.rst
deleted file mode 100644
index 752192b8..00000000
--- a/vendor/twig/twig/doc/filters/reverse.rst
+++ /dev/null
@@ -1,47 +0,0 @@
1``reverse``
2===========
3
4.. versionadded:: 1.6
5 Support for strings has been added in Twig 1.6.
6
7The ``reverse`` filter reverses a sequence, a mapping, or a string:
8
9.. code-block:: jinja
10
11 {% for user in users|reverse %}
12 ...
13 {% endfor %}
14
15 {{ '1234'|reverse }}
16
17 {# outputs 4321 #}
18
19.. tip::
20
21 For sequences and mappings, numeric keys are not preserved. To reverse
22 them as well, pass ``true`` as an argument to the ``reverse`` filter:
23
24 .. code-block:: jinja
25
26 {% for key, value in {1: "a", 2: "b", 3: "c"}|reverse %}
27 {{ key }}: {{ value }}
28 {%- endfor %}
29
30 {# output: 0: c 1: b 2: a #}
31
32 {% for key, value in {1: "a", 2: "b", 3: "c"}|reverse(true) %}
33 {{ key }}: {{ value }}
34 {%- endfor %}
35
36 {# output: 3: c 2: b 1: a #}
37
38.. note::
39
40 It also works with objects implementing the `Traversable`_ interface.
41
42Arguments
43---------
44
45 * ``preserve_keys``: Preserve keys when reversing a mapping or a sequence.
46
47.. _`Traversable`: http://php.net/Traversable
diff --git a/vendor/twig/twig/doc/filters/slice.rst b/vendor/twig/twig/doc/filters/slice.rst
deleted file mode 100644
index dbd5db37..00000000
--- a/vendor/twig/twig/doc/filters/slice.rst
+++ /dev/null
@@ -1,70 +0,0 @@
1``slice``
2===========
3
4.. versionadded:: 1.6
5 The slice filter was added in Twig 1.6.
6
7The ``slice`` filter extracts a slice of a sequence, a mapping, or a string:
8
9.. code-block:: jinja
10
11 {% for i in [1, 2, 3, 4, 5]|slice(1, 2) %}
12 {# will iterate over 2 and 3 #}
13 {% endfor %}
14
15 {{ '12345'|slice(1, 2) }}
16
17 {# outputs 23 #}
18
19You can use any valid expression for both the start and the length:
20
21.. code-block:: jinja
22
23 {% for i in [1, 2, 3, 4, 5]|slice(start, length) %}
24 {# ... #}
25 {% endfor %}
26
27As syntactic sugar, you can also use the ``[]`` notation:
28
29.. code-block:: jinja
30
31 {% for i in [1, 2, 3, 4, 5][start:length] %}
32 {# ... #}
33 {% endfor %}
34
35 {{ '12345'[1:2] }}
36
37 {# you can omit the first argument -- which is the same as 0 #}
38 {{ '12345'[:2] }} {# will display "12" #}
39
40 {# you can omit the last argument -- which will select everything till the end #}
41 {{ '12345'[2:] }} {# will display "345" #}
42
43The ``slice`` filter works as the `array_slice`_ PHP function for arrays and
44`substr`_ for strings.
45
46If the start is non-negative, the sequence will start at that start in the
47variable. If start is negative, the sequence will start that far from the end
48of the variable.
49
50If length is given and is positive, then the sequence will have up to that
51many elements in it. If the variable is shorter than the length, then only the
52available variable elements will be present. If length is given and is
53negative then the sequence will stop that many elements from the end of the
54variable. If it is omitted, then the sequence will have everything from offset
55up until the end of the variable.
56
57.. note::
58
59 It also works with objects implementing the `Traversable`_ interface.
60
61Arguments
62---------
63
64 * ``start``: The start of the slice
65 * ``length``: The size of the slice
66 * ``preserve_keys``: Whether to preserve key or not (when the input is an array)
67
68.. _`Traversable`: http://php.net/manual/en/class.traversable.php
69.. _`array_slice`: http://php.net/array_slice
70.. _`substr`: http://php.net/substr
diff --git a/vendor/twig/twig/doc/filters/sort.rst b/vendor/twig/twig/doc/filters/sort.rst
deleted file mode 100644
index 33311528..00000000
--- a/vendor/twig/twig/doc/filters/sort.rst
+++ /dev/null
@@ -1,17 +0,0 @@
1``sort``
2========
3
4The ``sort`` filter sorts an array:
5
6.. code-block:: jinja
7
8 {% for user in users|sort %}
9 ...
10 {% endfor %}
11
12.. note::
13
14 Internally, Twig uses the PHP `asort`_ function to maintain index
15 association.
16
17.. _`asort`: http://php.net/asort
diff --git a/vendor/twig/twig/doc/filters/split.rst b/vendor/twig/twig/doc/filters/split.rst
deleted file mode 100644
index 7cd2ca5b..00000000
--- a/vendor/twig/twig/doc/filters/split.rst
+++ /dev/null
@@ -1,53 +0,0 @@
1``split``
2=========
3
4.. versionadded:: 1.10.3
5 The split filter was added in Twig 1.10.3.
6
7The ``split`` filter splits a string by the given delimiter and returns a list
8of strings:
9
10.. code-block:: jinja
11
12 {{ "one,two,three"|split(',') }}
13 {# returns ['one', 'two', 'three'] #}
14
15You can also pass a ``limit`` argument:
16
17 * If ``limit`` is positive, the returned array will contain a maximum of
18 limit elements with the last element containing the rest of string;
19
20 * If ``limit`` is negative, all components except the last -limit are
21 returned;
22
23 * If ``limit`` is zero, then this is treated as 1.
24
25.. code-block:: jinja
26
27 {{ "one,two,three,four,five"|split(',', 3) }}
28 {# returns ['one', 'two', 'three,four,five'] #}
29
30If the ``delimiter`` is an empty string, then value will be split by equal
31chunks. Length is set by the ``limit`` argument (one character by default).
32
33.. code-block:: jinja
34
35 {{ "123"|split('') }}
36 {# returns ['1', '2', '3'] #}
37
38 {{ "aabbcc"|split('', 2) }}
39 {# returns ['aa', 'bb', 'cc'] #}
40
41.. note::
42
43 Internally, Twig uses the PHP `explode`_ or `str_split`_ (if delimiter is
44 empty) functions for string splitting.
45
46Arguments
47---------
48
49 * ``delimiter``: The delimiter
50 * ``limit``: The limit argument
51
52.. _`explode`: http://php.net/explode
53.. _`str_split`: http://php.net/str_split
diff --git a/vendor/twig/twig/doc/filters/striptags.rst b/vendor/twig/twig/doc/filters/striptags.rst
deleted file mode 100644
index 72c6f252..00000000
--- a/vendor/twig/twig/doc/filters/striptags.rst
+++ /dev/null
@@ -1,15 +0,0 @@
1``striptags``
2=============
3
4The ``striptags`` filter strips SGML/XML tags and replace adjacent whitespace
5by one space:
6
7.. code-block:: jinja
8
9 {{ some_html|striptags }}
10
11.. note::
12
13 Internally, Twig uses the PHP `strip_tags`_ function.
14
15.. _`strip_tags`: http://php.net/strip_tags
diff --git a/vendor/twig/twig/doc/filters/title.rst b/vendor/twig/twig/doc/filters/title.rst
deleted file mode 100644
index c5a318e8..00000000
--- a/vendor/twig/twig/doc/filters/title.rst
+++ /dev/null
@@ -1,11 +0,0 @@
1``title``
2=========
3
4The ``title`` filter returns a titlecased version of the value. Words will
5start with uppercase letters, all remaining characters are lowercase:
6
7.. code-block:: jinja
8
9 {{ 'my first car'|title }}
10
11 {# outputs 'My First Car' #}
diff --git a/vendor/twig/twig/doc/filters/trim.rst b/vendor/twig/twig/doc/filters/trim.rst
deleted file mode 100644
index f38afd55..00000000
--- a/vendor/twig/twig/doc/filters/trim.rst
+++ /dev/null
@@ -1,29 +0,0 @@
1``trim``
2========
3
4.. versionadded:: 1.6.2
5 The trim filter was added in Twig 1.6.2.
6
7The ``trim`` filter strips whitespace (or other characters) from the beginning
8and end of a string:
9
10.. code-block:: jinja
11
12 {{ ' I like Twig. '|trim }}
13
14 {# outputs 'I like Twig.' #}
15
16 {{ ' I like Twig.'|trim('.') }}
17
18 {# outputs ' I like Twig' #}
19
20.. note::
21
22 Internally, Twig uses the PHP `trim`_ function.
23
24Arguments
25---------
26
27 * ``character_mask``: The characters to strip
28
29.. _`trim`: http://php.net/trim
diff --git a/vendor/twig/twig/doc/filters/upper.rst b/vendor/twig/twig/doc/filters/upper.rst
deleted file mode 100644
index 561cebe3..00000000
--- a/vendor/twig/twig/doc/filters/upper.rst
+++ /dev/null
@@ -1,10 +0,0 @@
1``upper``
2=========
3
4The ``upper`` filter converts a value to uppercase:
5
6.. code-block:: jinja
7
8 {{ 'welcome'|upper }}
9
10 {# outputs 'WELCOME' #}
diff --git a/vendor/twig/twig/doc/filters/url_encode.rst b/vendor/twig/twig/doc/filters/url_encode.rst
deleted file mode 100644
index b4f9a6ca..00000000
--- a/vendor/twig/twig/doc/filters/url_encode.rst
+++ /dev/null
@@ -1,28 +0,0 @@
1``url_encode``
2==============
3
4.. versionadded:: 1.12.3
5 Support for encoding an array as query string was added in Twig 1.12.3.
6
7The ``url_encode`` filter percent encodes a given string as URL segment
8or an array as query string:
9
10.. code-block:: jinja
11
12 {{ "path-seg*ment"|url_encode }}
13 {# outputs "path-seg%2Ament" #}
14
15 {{ "string with spaces"|url_encode(true) }}
16 {# outputs "string%20with%20spaces" #}
17
18 {{ {'param': 'value', 'foo': 'bar'}|url_encode }}
19 {# outputs "param=value&foo=bar" #}
20
21.. note::
22
23 Internally, Twig uses the PHP `urlencode`_ (or `rawurlencode`_ if you pass
24 ``true`` as the first parameter) or the `http_build_query`_ function.
25
26.. _`urlencode`: http://php.net/urlencode
27.. _`rawurlencode`: http://php.net/rawurlencode
28.. _`http_build_query`: http://php.net/http_build_query
diff --git a/vendor/twig/twig/doc/functions/attribute.rst b/vendor/twig/twig/doc/functions/attribute.rst
deleted file mode 100644
index 3051bdaa..00000000
--- a/vendor/twig/twig/doc/functions/attribute.rst
+++ /dev/null
@@ -1,18 +0,0 @@
1``attribute``
2=============
3
4.. versionadded:: 1.2
5 The ``attribute`` function was added in Twig 1.2.
6
7``attribute`` can be used to access a "dynamic" attribute of a variable:
8
9.. code-block:: jinja
10
11 {{ attribute(object, method) }}
12 {{ attribute(object, method, arguments) }}
13 {{ attribute(array, item) }}
14
15.. note::
16
17 The resolution algorithm is the same as the one used for the ``.``
18 notation, except that the item can be any valid expression.
diff --git a/vendor/twig/twig/doc/functions/block.rst b/vendor/twig/twig/doc/functions/block.rst
deleted file mode 100644
index fd571efb..00000000
--- a/vendor/twig/twig/doc/functions/block.rst
+++ /dev/null
@@ -1,15 +0,0 @@
1``block``
2=========
3
4When a template uses inheritance and if you want to print a block multiple
5times, use the ``block`` function:
6
7.. code-block:: jinja
8
9 <title>{% block title %}{% endblock %}</title>
10
11 <h1>{{ block('title') }}</h1>
12
13 {% block body %}{% endblock %}
14
15.. seealso:: :doc:`extends<../tags/extends>`, :doc:`parent<../functions/parent>`
diff --git a/vendor/twig/twig/doc/functions/constant.rst b/vendor/twig/twig/doc/functions/constant.rst
deleted file mode 100644
index bea0e9fc..00000000
--- a/vendor/twig/twig/doc/functions/constant.rst
+++ /dev/null
@@ -1,18 +0,0 @@
1``constant``
2============
3
4.. versionadded: 1.12.1
5 constant now accepts object instances as the second argument.
6
7``constant`` returns the constant value for a given string:
8
9.. code-block:: jinja
10
11 {{ some_date|date(constant('DATE_W3C')) }}
12 {{ constant('Namespace\\Classname::CONSTANT_NAME') }}
13
14As of 1.12.1 you can read constants from object instances as well:
15
16.. code-block:: jinja
17
18 {{ constant('RSS', date) }}
diff --git a/vendor/twig/twig/doc/functions/cycle.rst b/vendor/twig/twig/doc/functions/cycle.rst
deleted file mode 100644
index 0015cae1..00000000
--- a/vendor/twig/twig/doc/functions/cycle.rst
+++ /dev/null
@@ -1,25 +0,0 @@
1``cycle``
2=========
3
4The ``cycle`` function cycles on an array of values:
5
6.. code-block:: jinja
7
8 {% for i in 0..10 %}
9 {{ cycle(['odd', 'even'], i) }}
10 {% endfor %}
11
12The array can contain any number of values:
13
14.. code-block:: jinja
15
16 {% set fruits = ['apple', 'orange', 'citrus'] %}
17
18 {% for i in 0..10 %}
19 {{ cycle(fruits, i) }}
20 {% endfor %}
21
22Arguments
23---------
24
25 * ``position``: The cycle position
diff --git a/vendor/twig/twig/doc/functions/date.rst b/vendor/twig/twig/doc/functions/date.rst
deleted file mode 100644
index f1c94819..00000000
--- a/vendor/twig/twig/doc/functions/date.rst
+++ /dev/null
@@ -1,52 +0,0 @@
1``date``
2========
3
4.. versionadded:: 1.6
5 The date function has been added in Twig 1.6.
6
7.. versionadded:: 1.6.1
8 The default timezone support has been added in Twig 1.6.1.
9
10Converts an argument to a date to allow date comparison:
11
12.. code-block:: jinja
13
14 {% if date(user.created_at) < date('-2days') %}
15 {# do something #}
16 {% endif %}
17
18The argument must be in a format supported by the `date`_ function.
19
20You can pass a timezone as the second argument:
21
22.. code-block:: jinja
23
24 {% if date(user.created_at) < date('-2days', 'Europe/Paris') %}
25 {# do something #}
26 {% endif %}
27
28If no argument is passed, the function returns the current date:
29
30.. code-block:: jinja
31
32 {% if date(user.created_at) < date() %}
33 {# always! #}
34 {% endif %}
35
36.. note::
37
38 You can set the default timezone globally by calling ``setTimezone()`` on
39 the ``core`` extension instance:
40
41 .. code-block:: php
42
43 $twig = new Twig_Environment($loader);
44 $twig->getExtension('core')->setTimezone('Europe/Paris');
45
46Arguments
47---------
48
49 * ``date``: The date
50 * ``timezone``: The timezone
51
52.. _`date`: http://www.php.net/date
diff --git a/vendor/twig/twig/doc/functions/dump.rst b/vendor/twig/twig/doc/functions/dump.rst
deleted file mode 100644
index 1500b0f4..00000000
--- a/vendor/twig/twig/doc/functions/dump.rst
+++ /dev/null
@@ -1,69 +0,0 @@
1``dump``
2========
3
4.. versionadded:: 1.5
5 The dump function was added in Twig 1.5.
6
7The ``dump`` function dumps information about a template variable. This is
8mostly useful to debug a template that does not behave as expected by
9introspecting its variables:
10
11.. code-block:: jinja
12
13 {{ dump(user) }}
14
15.. note::
16
17 The ``dump`` function is not available by default. You must add the
18 ``Twig_Extension_Debug`` extension explicitly when creating your Twig
19 environment::
20
21 $twig = new Twig_Environment($loader, array(
22 'debug' => true,
23 // ...
24 ));
25 $twig->addExtension(new Twig_Extension_Debug());
26
27 Even when enabled, the ``dump`` function won't display anything if the
28 ``debug`` option on the environment is not enabled (to avoid leaking debug
29 information on a production server).
30
31In an HTML context, wrap the output with a ``pre`` tag to make it easier to
32read:
33
34.. code-block:: jinja
35
36 <pre>
37 {{ dump(user) }}
38 </pre>
39
40.. tip::
41
42 Using a ``pre`` tag is not needed when `XDebug`_ is enabled and
43 ``html_errors`` is ``on``; as a bonus, the output is also nicer with
44 XDebug enabled.
45
46You can debug several variables by passing them as additional arguments:
47
48.. code-block:: jinja
49
50 {{ dump(user, categories) }}
51
52If you don't pass any value, all variables from the current context are
53dumped:
54
55.. code-block:: jinja
56
57 {{ dump() }}
58
59.. note::
60
61 Internally, Twig uses the PHP `var_dump`_ function.
62
63Arguments
64---------
65
66 * ``context``: The context to dump
67
68.. _`XDebug`: http://xdebug.org/docs/display
69.. _`var_dump`: http://php.net/var_dump
diff --git a/vendor/twig/twig/doc/functions/include.rst b/vendor/twig/twig/doc/functions/include.rst
deleted file mode 100644
index eaddfe61..00000000
--- a/vendor/twig/twig/doc/functions/include.rst
+++ /dev/null
@@ -1,80 +0,0 @@
1``include``
2===========
3
4.. versionadded:: 1.12
5 The include function was added in Twig 1.12.
6
7The ``include`` function returns the rendered content of a template:
8
9.. code-block:: jinja
10
11 {{ include('template.html') }}
12 {{ include(some_var) }}
13
14Included templates have access to the variables of the active context.
15
16If you are using the filesystem loader, the templates are looked for in the
17paths defined by it.
18
19The context is passed by default to the template but you can also pass
20additional variables:
21
22.. code-block:: jinja
23
24 {# template.html will have access to the variables from the current context and the additional ones provided #}
25 {{ include('template.html', {foo: 'bar'}) }}
26
27You can disable access to the context by setting ``with_context`` to
28``false``:
29
30.. code-block:: jinja
31
32 {# only the foo variable will be accessible #}
33 {{ include('template.html', {foo: 'bar'}, with_context = false) }}
34
35.. code-block:: jinja
36
37 {# no variables will be accessible #}
38 {{ include('template.html', with_context = false) }}
39
40And if the expression evaluates to a ``Twig_Template`` object, Twig will use it
41directly::
42
43 // {{ include(template) }}
44
45 $template = $twig->loadTemplate('some_template.twig');
46
47 $twig->loadTemplate('template.twig')->display(array('template' => $template));
48
49When you set the ``ignore_missing`` flag, Twig will return an empty string if
50the template does not exist:
51
52.. code-block:: jinja
53
54 {{ include('sidebar.html', ignore_missing = true) }}
55
56You can also provide a list of templates that are checked for existence before
57inclusion. The first template that exists will be rendered:
58
59.. code-block:: jinja
60
61 {{ include(['page_detailed.html', 'page.html']) }}
62
63If ``ignore_missing`` is set, it will fall back to rendering nothing if none
64of the templates exist, otherwise it will throw an exception.
65
66When including a template created by an end user, you should consider
67sandboxing it:
68
69.. code-block:: jinja
70
71 {{ include('page.html', sandboxed = true) }}
72
73Arguments
74---------
75
76 * ``template``: The template to render
77 * ``variables``: The variables to pass to the template
78 * ``with_context``: Whether to pass the current context variables or not
79 * ``ignore_missing``: Whether to ignore missing templates or not
80 * ``sandboxed``: Whether to sandbox the template or not
diff --git a/vendor/twig/twig/doc/functions/index.rst b/vendor/twig/twig/doc/functions/index.rst
deleted file mode 100644
index 8650cbdb..00000000
--- a/vendor/twig/twig/doc/functions/index.rst
+++ /dev/null
@@ -1,17 +0,0 @@
1Functions
2=========
3
4.. toctree::
5 :maxdepth: 1
6
7 attribute
8 block
9 constant
10 cycle
11 date
12 dump
13 include
14 parent
15 random
16 range
17 template_from_string
diff --git a/vendor/twig/twig/doc/functions/parent.rst b/vendor/twig/twig/doc/functions/parent.rst
deleted file mode 100644
index f5bd2001..00000000
--- a/vendor/twig/twig/doc/functions/parent.rst
+++ /dev/null
@@ -1,20 +0,0 @@
1``parent``
2==========
3
4When a template uses inheritance, it's possible to render the contents of the
5parent block when overriding a block by using the ``parent`` function:
6
7.. code-block:: jinja
8
9 {% extends "base.html" %}
10
11 {% block sidebar %}
12 <h3>Table Of Contents</h3>
13 ...
14 {{ parent() }}
15 {% endblock %}
16
17The ``parent()`` call will return the content of the ``sidebar`` block as
18defined in the ``base.html`` template.
19
20.. seealso:: :doc:`extends<../tags/extends>`, :doc:`block<../functions/block>`, :doc:`block<../tags/block>`
diff --git a/vendor/twig/twig/doc/functions/random.rst b/vendor/twig/twig/doc/functions/random.rst
deleted file mode 100644
index a5a916bb..00000000
--- a/vendor/twig/twig/doc/functions/random.rst
+++ /dev/null
@@ -1,29 +0,0 @@
1``random``
2==========
3
4.. versionadded:: 1.5
5 The random function was added in Twig 1.5.
6
7.. versionadded:: 1.6
8 String and integer handling was added in Twig 1.6.
9
10The ``random`` function returns a random value depending on the supplied
11parameter type:
12
13* a random item from a sequence;
14* a random character from a string;
15* a random integer between 0 and the integer parameter (inclusive).
16
17.. code-block:: jinja
18
19 {{ random(['apple', 'orange', 'citrus']) }} {# example output: orange #}
20 {{ random('ABC') }} {# example output: C #}
21 {{ random() }} {# example output: 15386094 (works as native PHP `mt_rand`_ function) #}
22 {{ random(5) }} {# example output: 3 #}
23
24Arguments
25---------
26
27 * ``values``: The values
28
29.. _`mt_rand`: http://php.net/mt_rand
diff --git a/vendor/twig/twig/doc/functions/range.rst b/vendor/twig/twig/doc/functions/range.rst
deleted file mode 100644
index b1fa5471..00000000
--- a/vendor/twig/twig/doc/functions/range.rst
+++ /dev/null
@@ -1,45 +0,0 @@
1``range``
2=========
3
4Returns a list containing an arithmetic progression of integers:
5
6.. code-block:: jinja
7
8 {% for i in range(0, 3) %}
9 {{ i }},
10 {% endfor %}
11
12 {# returns 0, 1, 2, 3 #}
13
14When step is given (as the third parameter), it specifies the increment (or
15decrement):
16
17.. code-block:: jinja
18
19 {% for i in range(0, 6, 2) %}
20 {{ i }},
21 {% endfor %}
22
23 {# returns 0, 2, 4, 6 #}
24
25The Twig built-in ``..`` operator is just syntactic sugar for the ``range``
26function (with a step of 1):
27
28.. code-block:: jinja
29
30 {% for i in 0..3 %}
31 {{ i }},
32 {% endfor %}
33
34.. tip::
35
36 The ``range`` function works as the native PHP `range`_ function.
37
38Arguments
39---------
40
41 * ``low``: The first value of the sequence.
42 * ``high``: The highest possible value of the sequence.
43 * ``step``: The increment between elements of the sequence.
44
45.. _`range`: http://php.net/range
diff --git a/vendor/twig/twig/doc/functions/template_from_string.rst b/vendor/twig/twig/doc/functions/template_from_string.rst
deleted file mode 100644
index bbb06d86..00000000
--- a/vendor/twig/twig/doc/functions/template_from_string.rst
+++ /dev/null
@@ -1,32 +0,0 @@
1``template_from_string``
2========================
3
4.. versionadded:: 1.11
5 The template_from_string function was added in Twig 1.11.
6
7The ``template_from_string`` function loads a template from a string:
8
9.. code-block:: jinja
10
11 {{ include(template_from_string("Hello {{ name }}") }}
12 {{ include(template_from_string(page.template)) }}
13
14.. note::
15
16 The ``template_from_string`` function is not available by default. You
17 must add the ``Twig_Extension_StringLoader`` extension explicitly when
18 creating your Twig environment::
19
20 $twig = new Twig_Environment(...);
21 $twig->addExtension(new Twig_Extension_StringLoader());
22
23.. note::
24
25 Even if you will probably always use the ``template_from_string`` function
26 with the ``include`` function, you can use it with any tag or function that
27 takes a template as an argument (like the ``embed`` or ``extends`` tags).
28
29Arguments
30---------
31
32 * ``template``: The template
diff --git a/vendor/twig/twig/doc/index.rst b/vendor/twig/twig/doc/index.rst
deleted file mode 100644
index 3e5166c6..00000000
--- a/vendor/twig/twig/doc/index.rst
+++ /dev/null
@@ -1,18 +0,0 @@
1Twig
2====
3
4.. toctree::
5 :maxdepth: 2
6
7 intro
8 templates
9 api
10 advanced
11 internals
12 recipes
13 coding_standards
14 tags/index
15 filters/index
16 functions/index
17 tests/index
18 deprecated
diff --git a/vendor/twig/twig/doc/internals.rst b/vendor/twig/twig/doc/internals.rst
deleted file mode 100644
index 79a3c8d5..00000000
--- a/vendor/twig/twig/doc/internals.rst
+++ /dev/null
@@ -1,140 +0,0 @@
1Twig Internals
2==============
3
4Twig is very extensible and you can easily hack it. Keep in mind that you
5should probably try to create an extension before hacking the core, as most
6features and enhancements can be done with extensions. This chapter is also
7useful for people who want to understand how Twig works under the hood.
8
9How Twig works?
10---------------
11
12The rendering of a Twig template can be summarized into four key steps:
13
14* **Load** the template: If the template is already compiled, load it and go
15 to the *evaluation* step, otherwise:
16
17 * First, the **lexer** tokenizes the template source code into small pieces
18 for easier processing;
19 * Then, the **parser** converts the token stream into a meaningful tree
20 of nodes (the Abstract Syntax Tree);
21 * Eventually, the *compiler* transforms the AST into PHP code;
22
23* **Evaluate** the template: It basically means calling the ``display()``
24 method of the compiled template and passing it the context.
25
26The Lexer
27---------
28
29The lexer tokenizes a template source code into a token stream (each token is
30an instance of ``Twig_Token``, and the stream is an instance of
31``Twig_TokenStream``). The default lexer recognizes 13 different token types:
32
33* ``Twig_Token::BLOCK_START_TYPE``, ``Twig_Token::BLOCK_END_TYPE``: Delimiters for blocks (``{% %}``)
34* ``Twig_Token::VAR_START_TYPE``, ``Twig_Token::VAR_END_TYPE``: Delimiters for variables (``{{ }}``)
35* ``Twig_Token::TEXT_TYPE``: A text outside an expression;
36* ``Twig_Token::NAME_TYPE``: A name in an expression;
37* ``Twig_Token::NUMBER_TYPE``: A number in an expression;
38* ``Twig_Token::STRING_TYPE``: A string in an expression;
39* ``Twig_Token::OPERATOR_TYPE``: An operator;
40* ``Twig_Token::PUNCTUATION_TYPE``: A punctuation sign;
41* ``Twig_Token::INTERPOLATION_START_TYPE``, ``Twig_Token::INTERPOLATION_END_TYPE`` (as of Twig 1.5): Delimiters for string interpolation;
42* ``Twig_Token::EOF_TYPE``: Ends of template.
43
44You can manually convert a source code into a token stream by calling the
45``tokenize()`` of an environment::
46
47 $stream = $twig->tokenize($source, $identifier);
48
49As the stream has a ``__toString()`` method, you can have a textual
50representation of it by echoing the object::
51
52 echo $stream."\n";
53
54Here is the output for the ``Hello {{ name }}`` template:
55
56.. code-block:: text
57
58 TEXT_TYPE(Hello )
59 VAR_START_TYPE()
60 NAME_TYPE(name)
61 VAR_END_TYPE()
62 EOF_TYPE()
63
64.. note::
65
66 You can change the default lexer use by Twig (``Twig_Lexer``) by calling
67 the ``setLexer()`` method::
68
69 $twig->setLexer($lexer);
70
71The Parser
72----------
73
74The parser converts the token stream into an AST (Abstract Syntax Tree), or a
75node tree (an instance of ``Twig_Node_Module``). The core extension defines
76the basic nodes like: ``for``, ``if``, ... and the expression nodes.
77
78You can manually convert a token stream into a node tree by calling the
79``parse()`` method of an environment::
80
81 $nodes = $twig->parse($stream);
82
83Echoing the node object gives you a nice representation of the tree::
84
85 echo $nodes."\n";
86
87Here is the output for the ``Hello {{ name }}`` template:
88
89.. code-block:: text
90
91 Twig_Node_Module(
92 Twig_Node_Text(Hello )
93 Twig_Node_Print(
94 Twig_Node_Expression_Name(name)
95 )
96 )
97
98.. note::
99
100 The default parser (``Twig_TokenParser``) can be also changed by calling the
101 ``setParser()`` method::
102
103 $twig->setParser($parser);
104
105The Compiler
106------------
107
108The last step is done by the compiler. It takes a node tree as an input and
109generates PHP code usable for runtime execution of the template.
110
111You can call the compiler by hand with the ``compile()`` method of an
112environment::
113
114 $php = $twig->compile($nodes);
115
116The ``compile()`` method returns the PHP source code representing the node.
117
118The generated template for a ``Hello {{ name }}`` template reads as follows
119(the actual output can differ depending on the version of Twig you are
120using)::
121
122 /* Hello {{ name }} */
123 class __TwigTemplate_1121b6f109fe93ebe8c6e22e3712bceb extends Twig_Template
124 {
125 protected function doDisplay(array $context, array $blocks = array())
126 {
127 // line 1
128 echo "Hello ";
129 echo twig_escape_filter($this->env, $this->getContext($context, "name"), "ndex", null, true);
130 }
131
132 // some more code
133 }
134
135.. note::
136
137 As for the lexer and the parser, the default compiler (``Twig_Compiler``) can
138 be changed by calling the ``setCompiler()`` method::
139
140 $twig->setCompiler($compiler);
diff --git a/vendor/twig/twig/doc/intro.rst b/vendor/twig/twig/doc/intro.rst
deleted file mode 100644
index bdcdb8a0..00000000
--- a/vendor/twig/twig/doc/intro.rst
+++ /dev/null
@@ -1,164 +0,0 @@
1Introduction
2============
3
4This is the documentation for Twig, the flexible, fast, and secure template
5engine for PHP.
6
7If you have any exposure to other text-based template languages, such as
8Smarty, Django, or Jinja, you should feel right at home with Twig. It's both
9designer and developer friendly by sticking to PHP's principles and adding
10functionality useful for templating environments.
11
12The key-features are...
13
14* *Fast*: Twig compiles templates down to plain optimized PHP code. The
15 overhead compared to regular PHP code was reduced to the very minimum.
16
17* *Secure*: Twig has a sandbox mode to evaluate untrusted template code. This
18 allows Twig to be used as a template language for applications where users
19 may modify the template design.
20
21* *Flexible*: Twig is powered by a flexible lexer and parser. This allows the
22 developer to define its own custom tags and filters, and create its own DSL.
23
24Prerequisites
25-------------
26
27Twig needs at least **PHP 5.2.4** to run.
28
29Installation
30------------
31
32You have multiple ways to install Twig.
33
34Installing via Composer (recommended)
35~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
36
371. Install composer in your project:
38
39.. code-block:: bash
40
41 curl -s http://getcomposer.org/installer | php
42
432. Create a ``composer.json`` file in your project root:
44
45.. code-block:: javascript
46
47 {
48 "require": {
49 "twig/twig": "1.*"
50 }
51 }
52
533. Install via composer
54
55.. code-block:: bash
56
57 php composer.phar install
58
59.. note::
60 If you want to learn more about Composer, the ``composer.json`` file syntax
61 and its usage, you can read the `online documentation`_.
62
63Installing from the tarball release
64~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
65
661. Download the most recent tarball from the `download page`_
672. Unpack the tarball
683. Move the files somewhere in your project
69
70Installing the development version
71~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
72
731. Install Git
742. ``git clone git://github.com/fabpot/Twig.git``
75
76Installing the PEAR package
77~~~~~~~~~~~~~~~~~~~~~~~~~~~
78
791. Install PEAR
802. ``pear channel-discover pear.twig-project.org``
813. ``pear install twig/Twig`` (or ``pear install twig/Twig-beta``)
82
83
84Installing the C extension
85~~~~~~~~~~~~~~~~~~~~~~~~~~
86
87.. versionadded:: 1.4
88 The C extension was added in Twig 1.4.
89
90Twig comes with a C extension that enhances the performance of the Twig
91runtime engine. You can install it like any other PHP extension:
92
93.. code-block:: bash
94
95 $ cd ext/twig
96 $ phpize
97 $ ./configure
98 $ make
99 $ make install
100
101Finally, enable the extension in your ``php.ini`` configuration file:
102
103.. code-block:: ini
104
105 extension=twig.so
106
107And from now on, Twig will automatically compile your templates to take
108advantage of the C extension. Note that this extension does not replace the
109PHP code but only provides an optimized version of the
110``Twig_Template::getAttribute()`` method.
111
112.. tip::
113
114 On Windows, you can also simply download and install a `pre-built DLL`_.
115
116Basic API Usage
117---------------
118
119This section gives you a brief introduction to the PHP API for Twig.
120
121The first step to use Twig is to register its autoloader::
122
123 require_once '/path/to/lib/Twig/Autoloader.php';
124 Twig_Autoloader::register();
125
126Replace the ``/path/to/lib/`` path with the path you used for Twig
127installation.
128
129If you have installed Twig via Composer you can take advantage of Composer's
130autoload mechanism by replacing the previous snippet for::
131
132 require_once '/path/to/vendor/autoload.php';
133
134.. note::
135
136 Twig follows the PEAR convention names for its classes, which means you
137 can easily integrate Twig classes loading in your own autoloader.
138
139.. code-block:: php
140
141 $loader = new Twig_Loader_String();
142 $twig = new Twig_Environment($loader);
143
144 echo $twig->render('Hello {{ name }}!', array('name' => 'Fabien'));
145
146Twig uses a loader (``Twig_Loader_String``) to locate templates, and an
147environment (``Twig_Environment``) to store the configuration.
148
149The ``render()`` method loads the template passed as a first argument and
150renders it with the variables passed as a second argument.
151
152As templates are generally stored on the filesystem, Twig also comes with a
153filesystem loader::
154
155 $loader = new Twig_Loader_Filesystem('/path/to/templates');
156 $twig = new Twig_Environment($loader, array(
157 'cache' => '/path/to/compilation_cache',
158 ));
159
160 echo $twig->render('index.html', array('name' => 'Fabien'));
161
162.. _`download page`: https://github.com/fabpot/Twig/tags
163.. _`online documentation`: http://getcomposer.org/doc
164.. _`pre-built DLL`: https://github.com/stealth35/stealth35.github.com/downloads
diff --git a/vendor/twig/twig/doc/recipes.rst b/vendor/twig/twig/doc/recipes.rst
deleted file mode 100644
index dfcc9205..00000000
--- a/vendor/twig/twig/doc/recipes.rst
+++ /dev/null
@@ -1,475 +0,0 @@
1Recipes
2=======
3
4Making a Layout conditional
5---------------------------
6
7Working with Ajax means that the same content is sometimes displayed as is,
8and sometimes decorated with a layout. As Twig layout template names can be
9any valid expression, you can pass a variable that evaluates to ``true`` when
10the request is made via Ajax and choose the layout accordingly:
11
12.. code-block:: jinja
13
14 {% extends request.ajax ? "base_ajax.html" : "base.html" %}
15
16 {% block content %}
17 This is the content to be displayed.
18 {% endblock %}
19
20Making an Include dynamic
21-------------------------
22
23When including a template, its name does not need to be a string. For
24instance, the name can depend on the value of a variable:
25
26.. code-block:: jinja
27
28 {% include var ~ '_foo.html' %}
29
30If ``var`` evaluates to ``index``, the ``index_foo.html`` template will be
31rendered.
32
33As a matter of fact, the template name can be any valid expression, such as
34the following:
35
36.. code-block:: jinja
37
38 {% include var|default('index') ~ '_foo.html' %}
39
40Overriding a Template that also extends itself
41----------------------------------------------
42
43A template can be customized in two different ways:
44
45* *Inheritance*: A template *extends* a parent template and overrides some
46 blocks;
47
48* *Replacement*: If you use the filesystem loader, Twig loads the first
49 template it finds in a list of configured directories; a template found in a
50 directory *replaces* another one from a directory further in the list.
51
52But how do you combine both: *replace* a template that also extends itself
53(aka a template in a directory further in the list)?
54
55Let's say that your templates are loaded from both ``.../templates/mysite``
56and ``.../templates/default`` in this order. The ``page.twig`` template,
57stored in ``.../templates/default`` reads as follows:
58
59.. code-block:: jinja
60
61 {# page.twig #}
62 {% extends "layout.twig" %}
63
64 {% block content %}
65 {% endblock %}
66
67You can replace this template by putting a file with the same name in
68``.../templates/mysite``. And if you want to extend the original template, you
69might be tempted to write the following:
70
71.. code-block:: jinja
72
73 {# page.twig in .../templates/mysite #}
74 {% extends "page.twig" %} {# from .../templates/default #}
75
76Of course, this will not work as Twig will always load the template from
77``.../templates/mysite``.
78
79It turns out it is possible to get this to work, by adding a directory right
80at the end of your template directories, which is the parent of all of the
81other directories: ``.../templates`` in our case. This has the effect of
82making every template file within our system uniquely addressable. Most of the
83time you will use the "normal" paths, but in the special case of wanting to
84extend a template with an overriding version of itself we can reference its
85parent's full, unambiguous template path in the extends tag:
86
87.. code-block:: jinja
88
89 {# page.twig in .../templates/mysite #}
90 {% extends "default/page.twig" %} {# from .../templates #}
91
92.. note::
93
94 This recipe was inspired by the following Django wiki page:
95 http://code.djangoproject.com/wiki/ExtendingTemplates
96
97Customizing the Syntax
98----------------------
99
100Twig allows some syntax customization for the block delimiters. It's not
101recommended to use this feature as templates will be tied with your custom
102syntax. But for specific projects, it can make sense to change the defaults.
103
104To change the block delimiters, you need to create your own lexer object::
105
106 $twig = new Twig_Environment();
107
108 $lexer = new Twig_Lexer($twig, array(
109 'tag_comment' => array('{#', '#}'),
110 'tag_block' => array('{%', '%}'),
111 'tag_variable' => array('{{', '}}'),
112 'interpolation' => array('#{', '}'),
113 ));
114 $twig->setLexer($lexer);
115
116Here are some configuration example that simulates some other template engines
117syntax::
118
119 // Ruby erb syntax
120 $lexer = new Twig_Lexer($twig, array(
121 'tag_comment' => array('<%#', '%>'),
122 'tag_block' => array('<%', '%>'),
123 'tag_variable' => array('<%=', '%>'),
124 ));
125
126 // SGML Comment Syntax
127 $lexer = new Twig_Lexer($twig, array(
128 'tag_comment' => array('<!--#', '-->'),
129 'tag_block' => array('<!--', '-->'),
130 'tag_variable' => array('${', '}'),
131 ));
132
133 // Smarty like
134 $lexer = new Twig_Lexer($twig, array(
135 'tag_comment' => array('{*', '*}'),
136 'tag_block' => array('{', '}'),
137 'tag_variable' => array('{$', '}'),
138 ));
139
140Using dynamic Object Properties
141-------------------------------
142
143When Twig encounters a variable like ``article.title``, it tries to find a
144``title`` public property in the ``article`` object.
145
146It also works if the property does not exist but is rather defined dynamically
147thanks to the magic ``__get()`` method; you just need to also implement the
148``__isset()`` magic method like shown in the following snippet of code::
149
150 class Article
151 {
152 public function __get($name)
153 {
154 if ('title' == $name) {
155 return 'The title';
156 }
157
158 // throw some kind of error
159 }
160
161 public function __isset($name)
162 {
163 if ('title' == $name) {
164 return true;
165 }
166
167 return false;
168 }
169 }
170
171Accessing the parent Context in Nested Loops
172--------------------------------------------
173
174Sometimes, when using nested loops, you need to access the parent context. The
175parent context is always accessible via the ``loop.parent`` variable. For
176instance, if you have the following template data::
177
178 $data = array(
179 'topics' => array(
180 'topic1' => array('Message 1 of topic 1', 'Message 2 of topic 1'),
181 'topic2' => array('Message 1 of topic 2', 'Message 2 of topic 2'),
182 ),
183 );
184
185And the following template to display all messages in all topics:
186
187.. code-block:: jinja
188
189 {% for topic, messages in topics %}
190 * {{ loop.index }}: {{ topic }}
191 {% for message in messages %}
192 - {{ loop.parent.loop.index }}.{{ loop.index }}: {{ message }}
193 {% endfor %}
194 {% endfor %}
195
196The output will be similar to:
197
198.. code-block:: text
199
200 * 1: topic1
201 - 1.1: The message 1 of topic 1
202 - 1.2: The message 2 of topic 1
203 * 2: topic2
204 - 2.1: The message 1 of topic 2
205 - 2.2: The message 2 of topic 2
206
207In the inner loop, the ``loop.parent`` variable is used to access the outer
208context. So, the index of the current ``topic`` defined in the outer for loop
209is accessible via the ``loop.parent.loop.index`` variable.
210
211Defining undefined Functions and Filters on the Fly
212---------------------------------------------------
213
214When a function (or a filter) is not defined, Twig defaults to throw a
215``Twig_Error_Syntax`` exception. However, it can also call a `callback`_ (any
216valid PHP callable) which should return a function (or a filter).
217
218For filters, register callbacks with ``registerUndefinedFilterCallback()``.
219For functions, use ``registerUndefinedFunctionCallback()``::
220
221 // auto-register all native PHP functions as Twig functions
222 // don't try this at home as it's not secure at all!
223 $twig->registerUndefinedFunctionCallback(function ($name) {
224 if (function_exists($name)) {
225 return new Twig_Function_Function($name);
226 }
227
228 return false;
229 });
230
231If the callable is not able to return a valid function (or filter), it must
232return ``false``.
233
234If you register more than one callback, Twig will call them in turn until one
235does not return ``false``.
236
237.. tip::
238
239 As the resolution of functions and filters is done during compilation,
240 there is no overhead when registering these callbacks.
241
242Validating the Template Syntax
243------------------------------
244
245When template code is providing by a third-party (through a web interface for
246instance), it might be interesting to validate the template syntax before
247saving it. If the template code is stored in a `$template` variable, here is
248how you can do it::
249
250 try {
251 $twig->parse($twig->tokenize($template));
252
253 // the $template is valid
254 } catch (Twig_Error_Syntax $e) {
255 // $template contains one or more syntax errors
256 }
257
258If you iterate over a set of files, you can pass the filename to the
259``tokenize()`` method to get the filename in the exception message::
260
261 foreach ($files as $file) {
262 try {
263 $twig->parse($twig->tokenize($template, $file));
264
265 // the $template is valid
266 } catch (Twig_Error_Syntax $e) {
267 // $template contains one or more syntax errors
268 }
269 }
270
271.. note::
272
273 This method won't catch any sandbox policy violations because the policy
274 is enforced during template rendering (as Twig needs the context for some
275 checks like allowed methods on objects).
276
277Refreshing modified Templates when APC is enabled and apc.stat = 0
278------------------------------------------------------------------
279
280When using APC with ``apc.stat`` set to ``0`` and Twig cache enabled, clearing
281the template cache won't update the APC cache. To get around this, one can
282extend ``Twig_Environment`` and force the update of the APC cache when Twig
283rewrites the cache::
284
285 class Twig_Environment_APC extends Twig_Environment
286 {
287 protected function writeCacheFile($file, $content)
288 {
289 parent::writeCacheFile($file, $content);
290
291 // Compile cached file into bytecode cache
292 apc_compile_file($file);
293 }
294 }
295
296Reusing a stateful Node Visitor
297-------------------------------
298
299When attaching a visitor to a ``Twig_Environment`` instance, Twig uses it to
300visit *all* templates it compiles. If you need to keep some state information
301around, you probably want to reset it when visiting a new template.
302
303This can be easily achieved with the following code::
304
305 protected $someTemplateState = array();
306
307 public function enterNode(Twig_NodeInterface $node, Twig_Environment $env)
308 {
309 if ($node instanceof Twig_Node_Module) {
310 // reset the state as we are entering a new template
311 $this->someTemplateState = array();
312 }
313
314 // ...
315
316 return $node;
317 }
318
319Using the Template name to set the default Escaping Strategy
320------------------------------------------------------------
321
322.. versionadded:: 1.8
323 This recipe requires Twig 1.8 or later.
324
325The ``autoescape`` option determines the default escaping strategy to use when
326no escaping is applied on a variable. When Twig is used to mostly generate
327HTML files, you can set it to ``html`` and explicitly change it to ``js`` when
328you have some dynamic JavaScript files thanks to the ``autoescape`` tag:
329
330.. code-block:: jinja
331
332 {% autoescape 'js' %}
333 ... some JS ...
334 {% endautoescape %}
335
336But if you have many HTML and JS files, and if your template names follow some
337conventions, you can instead determine the default escaping strategy to use
338based on the template name. Let's say that your template names always ends
339with ``.html`` for HTML files, ``.js`` for JavaScript ones, and ``.css`` for
340stylesheets, here is how you can configure Twig::
341
342 class TwigEscapingGuesser
343 {
344 function guess($filename)
345 {
346 // get the format
347 $format = substr($filename, strrpos($filename, '.') + 1);
348
349 switch ($format) {
350 case 'js':
351 return 'js';
352 case 'css':
353 return 'css';
354 case 'html':
355 default:
356 return 'html';
357 }
358 }
359 }
360
361 $loader = new Twig_Loader_Filesystem('/path/to/templates');
362 $twig = new Twig_Environment($loader, array(
363 'autoescape' => array(new TwigEscapingGuesser(), 'guess'),
364 ));
365
366This dynamic strategy does not incur any overhead at runtime as auto-escaping
367is done at compilation time.
368
369Using a Database to store Templates
370-----------------------------------
371
372If you are developing a CMS, templates are usually stored in a database. This
373recipe gives you a simple PDO template loader you can use as a starting point
374for your own.
375
376First, let's create a temporary in-memory SQLite3 database to work with::
377
378 $dbh = new PDO('sqlite::memory:');
379 $dbh->exec('CREATE TABLE templates (name STRING, source STRING, last_modified INTEGER)');
380 $base = '{% block content %}{% endblock %}';
381 $index = '
382 {% extends "base.twig" %}
383 {% block content %}Hello {{ name }}{% endblock %}
384 ';
385 $now = time();
386 $dbh->exec("INSERT INTO templates (name, source, last_modified) VALUES ('base.twig', '$base', $now)");
387 $dbh->exec("INSERT INTO templates (name, source, last_modified) VALUES ('index.twig', '$index', $now)");
388
389We have created a simple ``templates`` table that hosts two templates:
390``base.twig`` and ``index.twig``.
391
392Now, let's define a loader able to use this database::
393
394 class DatabaseTwigLoader implements Twig_LoaderInterface, Twig_ExistsLoaderInterface
395 {
396 protected $dbh;
397
398 public function __construct(PDO $dbh)
399 {
400 $this->dbh = $dbh;
401 }
402
403 public function getSource($name)
404 {
405 if (false === $source = $this->getValue('source', $name)) {
406 throw new Twig_Error_Loader(sprintf('Template "%s" does not exist.', $name));
407 }
408
409 return $source;
410 }
411
412 // Twig_ExistsLoaderInterface as of Twig 1.11
413 public function exists($name)
414 {
415 return $name === $this->getValue('name', $name);
416 }
417
418 public function getCacheKey($name)
419 {
420 return $name;
421 }
422
423 public function isFresh($name, $time)
424 {
425 if (false === $lastModified = $this->getValue('last_modified', $name)) {
426 return false;
427 }
428
429 return $lastModified <= $time;
430 }
431
432 protected function getValue($column, $name)
433 {
434 $sth = $this->dbh->prepare('SELECT '.$column.' FROM templates WHERE name = :name');
435 $sth->execute(array(':name' => (string) $name));
436
437 return $sth->fetchColumn();
438 }
439 }
440
441Finally, here is an example on how you can use it::
442
443 $loader = new DatabaseTwigLoader($dbh);
444 $twig = new Twig_Environment($loader);
445
446 echo $twig->render('index.twig', array('name' => 'Fabien'));
447
448Using different Template Sources
449--------------------------------
450
451This recipe is the continuation of the previous one. Even if you store the
452contributed templates in a database, you might want to keep the original/base
453templates on the filesystem. When templates can be loaded from different
454sources, you need to use the ``Twig_Loader_Chain`` loader.
455
456As you can see in the previous recipe, we reference the template in the exact
457same way as we would have done it with a regular filesystem loader. This is
458the key to be able to mix and match templates coming from the database, the
459filesystem, or any other loader for that matter: the template name should be a
460logical name, and not the path from the filesystem::
461
462 $loader1 = new DatabaseTwigLoader($dbh);
463 $loader2 = new Twig_Loader_Array(array(
464 'base.twig' => '{% block content %}{% endblock %}',
465 ));
466 $loader = new Twig_Loader_Chain(array($loader1, $loader2));
467
468 $twig = new Twig_Environment($loader);
469
470 echo $twig->render('index.twig', array('name' => 'Fabien'));
471
472Now that the ``base.twig`` templates is defined in an array loader, you can
473remove it from the database, and everything else will still work as before.
474
475.. _callback: http://www.php.net/manual/en/function.is-callable.php
diff --git a/vendor/twig/twig/doc/tags/autoescape.rst b/vendor/twig/twig/doc/tags/autoescape.rst
deleted file mode 100644
index c5ff0c2c..00000000
--- a/vendor/twig/twig/doc/tags/autoescape.rst
+++ /dev/null
@@ -1,71 +0,0 @@
1``autoescape``
2==============
3
4Whether automatic escaping is enabled or not, you can mark a section of a
5template to be escaped or not by using the ``autoescape`` tag:
6
7.. code-block:: jinja
8
9 {# The following syntax works as of Twig 1.8 -- see the note below for previous versions #}
10
11 {% autoescape %}
12 Everything will be automatically escaped in this block
13 using the HTML strategy
14 {% endautoescape %}
15
16 {% autoescape 'html' %}
17 Everything will be automatically escaped in this block
18 using the HTML strategy
19 {% endautoescape %}
20
21 {% autoescape 'js' %}
22 Everything will be automatically escaped in this block
23 using the js escaping strategy
24 {% endautoescape %}
25
26 {% autoescape false %}
27 Everything will be outputted as is in this block
28 {% endautoescape %}
29
30.. note::
31
32 Before Twig 1.8, the syntax was different:
33
34 .. code-block:: jinja
35
36 {% autoescape true %}
37 Everything will be automatically escaped in this block
38 using the HTML strategy
39 {% endautoescape %}
40
41 {% autoescape false %}
42 Everything will be outputted as is in this block
43 {% endautoescape %}
44
45 {% autoescape true js %}
46 Everything will be automatically escaped in this block
47 using the js escaping strategy
48 {% endautoescape %}
49
50When automatic escaping is enabled everything is escaped by default except for
51values explicitly marked as safe. Those can be marked in the template by using
52the :doc:`raw<../filters/raw>` filter:
53
54.. code-block:: jinja
55
56 {% autoescape %}
57 {{ safe_value|raw }}
58 {% endautoescape %}
59
60Functions returning template data (like :doc:`macros<macro>` and
61:doc:`parent<../functions/parent>`) always return safe markup.
62
63.. note::
64
65 Twig is smart enough to not escape an already escaped value by the
66 :doc:`escape<../filters/escape>` filter.
67
68.. note::
69
70 The chapter :doc:`Twig for Developers<../api>` gives more information
71 about when and how automatic escaping is applied.
diff --git a/vendor/twig/twig/doc/tags/block.rst b/vendor/twig/twig/doc/tags/block.rst
deleted file mode 100644
index e3804823..00000000
--- a/vendor/twig/twig/doc/tags/block.rst
+++ /dev/null
@@ -1,11 +0,0 @@
1``block``
2=========
3
4Blocks are used for inheritance and act as placeholders and replacements at
5the same time. They are documented in detail in the documentation for the
6:doc:`extends<../tags/extends>` tag.
7
8Block names should consist of alphanumeric characters, and underscores. Dashes
9are not permitted.
10
11.. seealso:: :doc:`block<../functions/block>`, :doc:`parent<../functions/parent>`, :doc:`use<../tags/use>`, :doc:`extends<../tags/extends>`
diff --git a/vendor/twig/twig/doc/tags/do.rst b/vendor/twig/twig/doc/tags/do.rst
deleted file mode 100644
index eca63d0a..00000000
--- a/vendor/twig/twig/doc/tags/do.rst
+++ /dev/null
@@ -1,12 +0,0 @@
1``do``
2======
3
4.. versionadded:: 1.5
5 The do tag was added in Twig 1.5.
6
7The ``do`` tag works exactly like the regular variable expression (``{{ ...
8}}``) just that it doesn't print anything:
9
10.. code-block:: jinja
11
12 {% do 1 + 2 %}
diff --git a/vendor/twig/twig/doc/tags/embed.rst b/vendor/twig/twig/doc/tags/embed.rst
deleted file mode 100644
index 5a6a0299..00000000
--- a/vendor/twig/twig/doc/tags/embed.rst
+++ /dev/null
@@ -1,178 +0,0 @@
1``embed``
2=========
3
4.. versionadded:: 1.8
5 The ``embed`` tag was added in Twig 1.8.
6
7The ``embed`` tag combines the behaviour of :doc:`include<include>` and
8:doc:`extends<extends>`.
9It allows you to include another template's contents, just like ``include``
10does. But it also allows you to override any block defined inside the
11included template, like when extending a template.
12
13Think of an embedded template as a "micro layout skeleton".
14
15.. code-block:: jinja
16
17 {% embed "teasers_skeleton.twig" %}
18 {# These blocks are defined in "teasers_skeleton.twig" #}
19 {# and we override them right here: #}
20 {% block left_teaser %}
21 Some content for the left teaser box
22 {% endblock %}
23 {% block right_teaser %}
24 Some content for the right teaser box
25 {% endblock %}
26 {% endembed %}
27
28The ``embed`` tag takes the idea of template inheritance to the level of
29content fragments. While template inheritance allows for "document skeletons",
30which are filled with life by child templates, the ``embed`` tag allows you to
31create "skeletons" for smaller units of content and re-use and fill them
32anywhere you like.
33
34Since the use case may not be obvious, let's look at a simplified example.
35Imagine a base template shared by multiple HTML pages, defining a single block
36named "content":
37
38.. code-block:: text
39
40 ┌─── page layout ─────────────────────┐
41 │ │
42 │ ┌── block "content" ──┐ │
43 │ │ │ │
44 │ │ │ │
45 │ │ (child template to │ │
46 │ │ put content here) │ │
47 │ │ │ │
48 │ │ │ │
49 │ └─────────────────────┘ │
50 │ │
51 └─────────────────────────────────────┘
52
53Some pages ("foo" and "bar") share the same content structure -
54two vertically stacked boxes:
55
56.. code-block:: text
57
58 ┌─── page layout ─────────────────────┐
59 │ │
60 │ ┌── block "content" ──┐ │
61 │ │ ┌─ block "top" ───┐ │ │
62 │ │ │ │ │ │
63 │ │ └─────────────────┘ │ │
64 │ │ ┌─ block "bottom" ┐ │ │
65 │ │ │ │ │ │
66 │ │ └─────────────────┘ │ │
67 │ └─────────────────────┘ │
68 │ │
69 └─────────────────────────────────────┘
70
71While other pages ("boom" and "baz") share a different content structure -
72two boxes side by side:
73
74.. code-block:: text
75
76 ┌─── page layout ─────────────────────┐
77 │ │
78 │ ┌── block "content" ──┐ │
79 │ │ │ │
80 │ │ ┌ block ┐ ┌ block ┐ │ │
81 │ │ │"left" │ │"right"│ │ │
82 │ │ │ │ │ │ │ │
83 │ │ │ │ │ │ │ │
84 │ │ └───────┘ └───────┘ │ │
85 │ └─────────────────────┘ │
86 │ │
87 └─────────────────────────────────────┘
88
89Without the ``embed`` tag, you have two ways to design your templates:
90
91 * Create two "intermediate" base templates that extend the master layout
92 template: one with vertically stacked boxes to be used by the "foo" and
93 "bar" pages and another one with side-by-side boxes for the "boom" and
94 "baz" pages.
95
96 * Embed the markup for the top/bottom and left/right boxes into each page
97 template directly.
98
99These two solutions do not scale well because they each have a major drawback:
100
101 * The first solution may indeed work for this simplified example. But imagine
102 we add a sidebar, which may again contain different, recurring structures
103 of content. Now we would need to create intermediate base templates for
104 all occurring combinations of content structure and sidebar structure...
105 and so on.
106
107 * The second solution involves duplication of common code with all its negative
108 consequences: any change involves finding and editing all affected copies
109 of the structure, correctness has to be verified for each copy, copies may
110 go out of sync by careless modifications etc.
111
112In such a situation, the ``embed`` tag comes in handy. The common layout
113code can live in a single base template, and the two different content structures,
114let's call them "micro layouts" go into separate templates which are embedded
115as necessary:
116
117Page template ``foo.twig``:
118
119.. code-block:: jinja
120
121 {% extends "layout_skeleton.twig" %}
122
123 {% block content %}
124 {% embed "vertical_boxes_skeleton.twig" %}
125 {% block top %}
126 Some content for the top box
127 {% endblock %}
128
129 {% block bottom %}
130 Some content for the bottom box
131 {% endblock %}
132 {% endembed %}
133 {% endblock %}
134
135And here is the code for ``vertical_boxes_skeleton.twig``:
136
137.. code-block:: html+jinja
138
139 <div class="top_box">
140 {% block top %}
141 Top box default content
142 {% endblock %}
143 </div>
144
145 <div class="bottom_box">
146 {% block bottom %}
147 Bottom box default content
148 {% endblock %}
149 </div>
150
151The goal of the ``vertical_boxes_skeleton.twig`` template being to factor
152out the HTML markup for the boxes.
153
154The ``embed`` tag takes the exact same arguments as the ``include`` tag:
155
156.. code-block:: jinja
157
158 {% embed "base" with {'foo': 'bar'} %}
159 ...
160 {% endembed %}
161
162 {% embed "base" with {'foo': 'bar'} only %}
163 ...
164 {% endembed %}
165
166 {% embed "base" ignore missing %}
167 ...
168 {% endembed %}
169
170.. warning::
171
172 As embedded templates do not have "names", auto-escaping strategies based
173 on the template "filename" won't work as expected if you change the
174 context (for instance, if you embed a CSS/JavaScript template into an HTML
175 one). In that case, explicitly set the default auto-escaping strategy with
176 the ``autoescape`` tag.
177
178.. seealso:: :doc:`include<../tags/include>`
diff --git a/vendor/twig/twig/doc/tags/extends.rst b/vendor/twig/twig/doc/tags/extends.rst
deleted file mode 100644
index f995a5dc..00000000
--- a/vendor/twig/twig/doc/tags/extends.rst
+++ /dev/null
@@ -1,268 +0,0 @@
1``extends``
2===========
3
4The ``extends`` tag can be used to extend a template from another one.
5
6.. note::
7
8 Like PHP, Twig does not support multiple inheritance. So you can only have
9 one extends tag called per rendering. However, Twig supports horizontal
10 :doc:`reuse<use>`.
11
12Let's define a base template, ``base.html``, which defines a simple HTML
13skeleton document:
14
15.. code-block:: html+jinja
16
17 <!DOCTYPE html>
18 <html>
19 <head>
20 {% block head %}
21 <link rel="stylesheet" href="style.css" />
22 <title>{% block title %}{% endblock %} - My Webpage</title>
23 {% endblock %}
24 </head>
25 <body>
26 <div id="content">{% block content %}{% endblock %}</div>
27 <div id="footer">
28 {% block footer %}
29 &copy; Copyright 2011 by <a href="http://domain.invalid/">you</a>.
30 {% endblock %}
31 </div>
32 </body>
33 </html>
34
35In this example, the :doc:`block<block>` tags define four blocks that child
36templates can fill in.
37
38All the ``block`` tag does is to tell the template engine that a child
39template may override those portions of the template.
40
41Child Template
42--------------
43
44A child template might look like this:
45
46.. code-block:: jinja
47
48 {% extends "base.html" %}
49
50 {% block title %}Index{% endblock %}
51 {% block head %}
52 {{ parent() }}
53 <style type="text/css">
54 .important { color: #336699; }
55 </style>
56 {% endblock %}
57 {% block content %}
58 <h1>Index</h1>
59 <p class="important">
60 Welcome on my awesome homepage.
61 </p>
62 {% endblock %}
63
64The ``extends`` tag is the key here. It tells the template engine that this
65template "extends" another template. When the template system evaluates this
66template, first it locates the parent. The extends tag should be the first tag
67in the template.
68
69Note that since the child template doesn't define the ``footer`` block, the
70value from the parent template is used instead.
71
72You can't define multiple ``block`` tags with the same name in the same
73template. This limitation exists because a block tag works in "both"
74directions. That is, a block tag doesn't just provide a hole to fill - it also
75defines the content that fills the hole in the *parent*. If there were two
76similarly-named ``block`` tags in a template, that template's parent wouldn't
77know which one of the blocks' content to use.
78
79If you want to print a block multiple times you can however use the
80``block`` function:
81
82.. code-block:: jinja
83
84 <title>{% block title %}{% endblock %}</title>
85 <h1>{{ block('title') }}</h1>
86 {% block body %}{% endblock %}
87
88Parent Blocks
89-------------
90
91It's possible to render the contents of the parent block by using the
92:doc:`parent<../functions/parent>` function. This gives back the results of
93the parent block:
94
95.. code-block:: jinja
96
97 {% block sidebar %}
98 <h3>Table Of Contents</h3>
99 ...
100 {{ parent() }}
101 {% endblock %}
102
103Named Block End-Tags
104--------------------
105
106Twig allows you to put the name of the block after the end tag for better
107readability:
108
109.. code-block:: jinja
110
111 {% block sidebar %}
112 {% block inner_sidebar %}
113 ...
114 {% endblock inner_sidebar %}
115 {% endblock sidebar %}
116
117Of course, the name after the ``endblock`` word must match the block name.
118
119Block Nesting and Scope
120-----------------------
121
122Blocks can be nested for more complex layouts. Per default, blocks have access
123to variables from outer scopes:
124
125.. code-block:: jinja
126
127 {% for item in seq %}
128 <li>{% block loop_item %}{{ item }}{% endblock %}</li>
129 {% endfor %}
130
131Block Shortcuts
132---------------
133
134For blocks with few content, it's possible to use a shortcut syntax. The
135following constructs do the same:
136
137.. code-block:: jinja
138
139 {% block title %}
140 {{ page_title|title }}
141 {% endblock %}
142
143.. code-block:: jinja
144
145 {% block title page_title|title %}
146
147Dynamic Inheritance
148-------------------
149
150Twig supports dynamic inheritance by using a variable as the base template:
151
152.. code-block:: jinja
153
154 {% extends some_var %}
155
156If the variable evaluates to a ``Twig_Template`` object, Twig will use it as
157the parent template::
158
159 // {% extends layout %}
160
161 $layout = $twig->loadTemplate('some_layout_template.twig');
162
163 $twig->display('template.twig', array('layout' => $layout));
164
165.. versionadded:: 1.2
166 The possibility to pass an array of templates has been added in Twig 1.2.
167
168You can also provide a list of templates that are checked for existence. The
169first template that exists will be used as a parent:
170
171.. code-block:: jinja
172
173 {% extends ['layout.html', 'base_layout.html'] %}
174
175Conditional Inheritance
176-----------------------
177
178As the template name for the parent can be any valid Twig expression, it's
179possible to make the inheritance mechanism conditional:
180
181.. code-block:: jinja
182
183 {% extends standalone ? "minimum.html" : "base.html" %}
184
185In this example, the template will extend the "minimum.html" layout template
186if the ``standalone`` variable evaluates to ``true``, and "base.html"
187otherwise.
188
189How blocks work?
190----------------
191
192A block provides a way to change how a certain part of a template is rendered
193but it does not interfere in any way with the logic around it.
194
195Let's take the following example to illustrate how a block work and more
196importantly, how it does not work:
197
198.. code-block:: jinja
199
200 {# base.twig #}
201
202 {% for post in posts %}
203 {% block post %}
204 <h1>{{ post.title }}</h1>
205 <p>{{ post.body }}</p>
206 {% endblock %}
207 {% endfor %}
208
209If you render this template, the result would be exactly the same with or
210without the ``block`` tag. The ``block`` inside the ``for`` loop is just a way
211to make it overridable by a child template:
212
213.. code-block:: jinja
214
215 {# child.twig #}
216
217 {% extends "base.twig" %}
218
219 {% block post %}
220 <article>
221 <header>{{ post.title }}</header>
222 <section>{{ post.text }}</section>
223 </article>
224 {% endblock %}
225
226Now, when rendering the child template, the loop is going to use the block
227defined in the child template instead of the one defined in the base one; the
228executed template is then equivalent to the following one:
229
230.. code-block:: jinja
231
232 {% for post in posts %}
233 <article>
234 <header>{{ post.title }}</header>
235 <section>{{ post.text }}</section>
236 </article>
237 {% endfor %}
238
239Let's take another example: a block included within an ``if`` statement:
240
241.. code-block:: jinja
242
243 {% if posts is empty %}
244 {% block head %}
245 {{ parent() }}
246
247 <meta name="robots" content="noindex, follow">
248 {% endblock head %}
249 {% endif %}
250
251Contrary to what you might think, this template does not define a block
252conditionally; it just makes overridable by a child template the output of
253what will be rendered when the condition is ``true``.
254
255If you want the output to be displayed conditionally, use the following
256instead:
257
258.. code-block:: jinja
259
260 {% block head %}
261 {{ parent() }}
262
263 {% if posts is empty %}
264 <meta name="robots" content="noindex, follow">
265 {% endif %}
266 {% endblock head %}
267
268.. seealso:: :doc:`block<../functions/block>`, :doc:`block<../tags/block>`, :doc:`parent<../functions/parent>`, :doc:`use<../tags/use>`
diff --git a/vendor/twig/twig/doc/tags/filter.rst b/vendor/twig/twig/doc/tags/filter.rst
deleted file mode 100644
index 82ca5c62..00000000
--- a/vendor/twig/twig/doc/tags/filter.rst
+++ /dev/null
@@ -1,21 +0,0 @@
1``filter``
2==========
3
4Filter sections allow you to apply regular Twig filters on a block of template
5data. Just wrap the code in the special ``filter`` section:
6
7.. code-block:: jinja
8
9 {% filter upper %}
10 This text becomes uppercase
11 {% endfilter %}
12
13You can also chain filters:
14
15.. code-block:: jinja
16
17 {% filter lower|escape %}
18 <strong>SOME TEXT</strong>
19 {% endfilter %}
20
21 {# outputs "&lt;strong&gt;some text&lt;/strong&gt;" #}
diff --git a/vendor/twig/twig/doc/tags/flush.rst b/vendor/twig/twig/doc/tags/flush.rst
deleted file mode 100644
index 55ef593a..00000000
--- a/vendor/twig/twig/doc/tags/flush.rst
+++ /dev/null
@@ -1,17 +0,0 @@
1``flush``
2=========
3
4.. versionadded:: 1.5
5 The flush tag was added in Twig 1.5.
6
7The ``flush`` tag tells Twig to flush the output buffer:
8
9.. code-block:: jinja
10
11 {% flush %}
12
13.. note::
14
15 Internally, Twig uses the PHP `flush`_ function.
16
17.. _`flush`: http://php.net/flush
diff --git a/vendor/twig/twig/doc/tags/for.rst b/vendor/twig/twig/doc/tags/for.rst
deleted file mode 100644
index 0673b551..00000000
--- a/vendor/twig/twig/doc/tags/for.rst
+++ /dev/null
@@ -1,172 +0,0 @@
1``for``
2=======
3
4Loop over each item in a sequence. For example, to display a list of users
5provided in a variable called ``users``:
6
7.. code-block:: jinja
8
9 <h1>Members</h1>
10 <ul>
11 {% for user in users %}
12 <li>{{ user.username|e }}</li>
13 {% endfor %}
14 </ul>
15
16.. note::
17
18 A sequence can be either an array or an object implementing the
19 ``Traversable`` interface.
20
21If you do need to iterate over a sequence of numbers, you can use the ``..``
22operator:
23
24.. code-block:: jinja
25
26 {% for i in 0..10 %}
27 * {{ i }}
28 {% endfor %}
29
30The above snippet of code would print all numbers from 0 to 10.
31
32It can be also useful with letters:
33
34.. code-block:: jinja
35
36 {% for letter in 'a'..'z' %}
37 * {{ letter }}
38 {% endfor %}
39
40The ``..`` operator can take any expression at both sides:
41
42.. code-block:: jinja
43
44 {% for letter in 'a'|upper..'z'|upper %}
45 * {{ letter }}
46 {% endfor %}
47
48.. tip:
49
50 If you need a step different from 1, you can use the ``range`` function
51 instead.
52
53The `loop` variable
54-------------------
55
56Inside of a ``for`` loop block you can access some special variables:
57
58===================== =============================================================
59Variable Description
60===================== =============================================================
61``loop.index`` The current iteration of the loop. (1 indexed)
62``loop.index0`` The current iteration of the loop. (0 indexed)
63``loop.revindex`` The number of iterations from the end of the loop (1 indexed)
64``loop.revindex0`` The number of iterations from the end of the loop (0 indexed)
65``loop.first`` True if first iteration
66``loop.last`` True if last iteration
67``loop.length`` The number of items in the sequence
68``loop.parent`` The parent context
69===================== =============================================================
70
71.. code-block:: jinja
72
73 {% for user in users %}
74 {{ loop.index }} - {{ user.username }}
75 {% endfor %}
76
77.. note::
78
79 The ``loop.length``, ``loop.revindex``, ``loop.revindex0``, and
80 ``loop.last`` variables are only available for PHP arrays, or objects that
81 implement the ``Countable`` interface. They are also not available when
82 looping with a condition.
83
84.. versionadded:: 1.2
85 The ``if`` modifier support has been added in Twig 1.2.
86
87Adding a condition
88------------------
89
90Unlike in PHP, it's not possible to ``break`` or ``continue`` in a loop. You
91can however filter the sequence during iteration which allows you to skip
92items. The following example skips all the users which are not active:
93
94.. code-block:: jinja
95
96 <ul>
97 {% for user in users if user.active %}
98 <li>{{ user.username|e }}</li>
99 {% endfor %}
100 </ul>
101
102The advantage is that the special loop variable will count correctly thus not
103counting the users not iterated over. Keep in mind that properties like
104``loop.last`` will not be defined when using loop conditions.
105
106.. note::
107
108 Using the ``loop`` variable within the condition is not recommended as it
109 will probably not be doing what you expect it to. For instance, adding a
110 condition like ``loop.index > 4`` won't work as the index is only
111 incremented when the condition is true (so the condition will never
112 match).
113
114The `else` Clause
115-----------------
116
117If no iteration took place because the sequence was empty, you can render a
118replacement block by using ``else``:
119
120.. code-block:: jinja
121
122 <ul>
123 {% for user in users %}
124 <li>{{ user.username|e }}</li>
125 {% else %}
126 <li><em>no user found</em></li>
127 {% endfor %}
128 </ul>
129
130Iterating over Keys
131-------------------
132
133By default, a loop iterates over the values of the sequence. You can iterate
134on keys by using the ``keys`` filter:
135
136.. code-block:: jinja
137
138 <h1>Members</h1>
139 <ul>
140 {% for key in users|keys %}
141 <li>{{ key }}</li>
142 {% endfor %}
143 </ul>
144
145Iterating over Keys and Values
146------------------------------
147
148You can also access both keys and values:
149
150.. code-block:: jinja
151
152 <h1>Members</h1>
153 <ul>
154 {% for key, user in users %}
155 <li>{{ key }}: {{ user.username|e }}</li>
156 {% endfor %}
157 </ul>
158
159Iterating over a Subset
160-----------------------
161
162You might want to iterate over a subset of values. This can be achieved using
163the :doc:`slice <../filters/slice>` filter:
164
165.. code-block:: jinja
166
167 <h1>Top Ten Members</h1>
168 <ul>
169 {% for user in users|slice(0, 10) %}
170 <li>{{ user.username|e }}</li>
171 {% endfor %}
172 </ul>
diff --git a/vendor/twig/twig/doc/tags/from.rst b/vendor/twig/twig/doc/tags/from.rst
deleted file mode 100644
index 5337a235..00000000
--- a/vendor/twig/twig/doc/tags/from.rst
+++ /dev/null
@@ -1,8 +0,0 @@
1``from``
2========
3
4The ``from`` tags import :doc:`macro<../tags/macro>` names into the current
5namespace. The tag is documented in detail in the documentation for the
6:doc:`import<../tags/import>` tag.
7
8.. seealso:: :doc:`macro<../tags/macro>`, :doc:`import<../tags/import>`
diff --git a/vendor/twig/twig/doc/tags/if.rst b/vendor/twig/twig/doc/tags/if.rst
deleted file mode 100644
index d7a1451c..00000000
--- a/vendor/twig/twig/doc/tags/if.rst
+++ /dev/null
@@ -1,43 +0,0 @@
1``if``
2======
3
4The ``if`` statement in Twig is comparable with the if statements of PHP.
5
6In the simplest form you can use it to test if an expression evaluates to
7``true``:
8
9.. code-block:: jinja
10
11 {% if online == false %}
12 <p>Our website is in maintenance mode. Please, come back later.</p>
13 {% endif %}
14
15You can also test if an array is not empty:
16
17.. code-block:: jinja
18
19 {% if users %}
20 <ul>
21 {% for user in users %}
22 <li>{{ user.username|e }}</li>
23 {% endfor %}
24 </ul>
25 {% endif %}
26
27.. note::
28
29 If you want to test if the variable is defined, use ``if users is
30 defined`` instead.
31
32For multiple branches ``elseif`` and ``else`` can be used like in PHP. You can use
33more complex ``expressions`` there too:
34
35.. code-block:: jinja
36
37 {% if kenny.sick %}
38 Kenny is sick.
39 {% elseif kenny.dead %}
40 You killed Kenny! You bastard!!!
41 {% else %}
42 Kenny looks okay --- so far
43 {% endif %}
diff --git a/vendor/twig/twig/doc/tags/import.rst b/vendor/twig/twig/doc/tags/import.rst
deleted file mode 100644
index f6bf718e..00000000
--- a/vendor/twig/twig/doc/tags/import.rst
+++ /dev/null
@@ -1,57 +0,0 @@
1``import``
2==========
3
4Twig supports putting often used code into :doc:`macros<../tags/macro>`. These
5macros can go into different templates and get imported from there.
6
7There are two ways to import templates. You can import the complete template
8into a variable or request specific macros from it.
9
10Imagine we have a helper module that renders forms (called ``forms.html``):
11
12.. code-block:: jinja
13
14 {% macro input(name, value, type, size) %}
15 <input type="{{ type|default('text') }}" name="{{ name }}" value="{{ value|e }}" size="{{ size|default(20) }}" />
16 {% endmacro %}
17
18 {% macro textarea(name, value, rows) %}
19 <textarea name="{{ name }}" rows="{{ rows|default(10) }}" cols="{{ cols|default(40) }}">{{ value|e }}</textarea>
20 {% endmacro %}
21
22The easiest and most flexible is importing the whole module into a variable.
23That way you can access the attributes:
24
25.. code-block:: jinja
26
27 {% import 'forms.html' as forms %}
28
29 <dl>
30 <dt>Username</dt>
31 <dd>{{ forms.input('username') }}</dd>
32 <dt>Password</dt>
33 <dd>{{ forms.input('password', null, 'password') }}</dd>
34 </dl>
35 <p>{{ forms.textarea('comment') }}</p>
36
37Alternatively you can import names from the template into the current
38namespace:
39
40.. code-block:: jinja
41
42 {% from 'forms.html' import input as input_field, textarea %}
43
44 <dl>
45 <dt>Username</dt>
46 <dd>{{ input_field('username') }}</dd>
47 <dt>Password</dt>
48 <dd>{{ input_field('password', '', 'password') }}</dd>
49 </dl>
50 <p>{{ textarea('comment') }}</p>
51
52.. tip::
53
54 To import macros from the current file, use the special ``_self`` variable
55 for the source.
56
57.. seealso:: :doc:`macro<../tags/macro>`, :doc:`from<../tags/from>`
diff --git a/vendor/twig/twig/doc/tags/include.rst b/vendor/twig/twig/doc/tags/include.rst
deleted file mode 100644
index 10b262de..00000000
--- a/vendor/twig/twig/doc/tags/include.rst
+++ /dev/null
@@ -1,86 +0,0 @@
1``include``
2===========
3
4The ``include`` statement includes a template and return the rendered content
5of that file into the current namespace:
6
7.. code-block:: jinja
8
9 {% include 'header.html' %}
10 Body
11 {% include 'footer.html' %}
12
13Included templates have access to the variables of the active context.
14
15If you are using the filesystem loader, the templates are looked for in the
16paths defined by it.
17
18You can add additional variables by passing them after the ``with`` keyword:
19
20.. code-block:: jinja
21
22 {# template.html will have access to the variables from the current context and the additional ones provided #}
23 {% include 'template.html' with {'foo': 'bar'} %}
24
25 {% set vars = {'foo': 'bar'} %}
26 {% include 'template.html' with vars %}
27
28You can disable access to the context by appending the ``only`` keyword:
29
30.. code-block:: jinja
31
32 {# only the foo variable will be accessible #}
33 {% include 'template.html' with {'foo': 'bar'} only %}
34
35.. code-block:: jinja
36
37 {# no variables will be accessible #}
38 {% include 'template.html' only %}
39
40.. tip::
41
42 When including a template created by an end user, you should consider
43 sandboxing it. More information in the :doc:`Twig for Developers<../api>`
44 chapter and in the :doc:`sandbox<../tags/sandbox>` tag documentation.
45
46The template name can be any valid Twig expression:
47
48.. code-block:: jinja
49
50 {% include some_var %}
51 {% include ajax ? 'ajax.html' : 'not_ajax.html' %}
52
53And if the expression evaluates to a ``Twig_Template`` object, Twig will use it
54directly::
55
56 // {% include template %}
57
58 $template = $twig->loadTemplate('some_template.twig');
59
60 $twig->loadTemplate('template.twig')->display(array('template' => $template));
61
62.. versionadded:: 1.2
63 The ``ignore missing`` feature has been added in Twig 1.2.
64
65You can mark an include with ``ignore missing`` in which case Twig will ignore
66the statement if the template to be included does not exist. It has to be
67placed just after the template name. Here some valid examples:
68
69.. code-block:: jinja
70
71 {% include 'sidebar.html' ignore missing %}
72 {% include 'sidebar.html' ignore missing with {'foo': 'bar'} %}
73 {% include 'sidebar.html' ignore missing only %}
74
75.. versionadded:: 1.2
76 The possibility to pass an array of templates has been added in Twig 1.2.
77
78You can also provide a list of templates that are checked for existence before
79inclusion. The first template that exists will be included:
80
81.. code-block:: jinja
82
83 {% include ['page_detailed.html', 'page.html'] %}
84
85If ``ignore missing`` is given, it will fall back to rendering nothing if none
86of the templates exist, otherwise it will throw an exception.
diff --git a/vendor/twig/twig/doc/tags/index.rst b/vendor/twig/twig/doc/tags/index.rst
deleted file mode 100644
index 64e88644..00000000
--- a/vendor/twig/twig/doc/tags/index.rst
+++ /dev/null
@@ -1,24 +0,0 @@
1Tags
2====
3
4.. toctree::
5 :maxdepth: 1
6
7 autoescape
8 block
9 filter
10 do
11 embed
12 extends
13 flush
14 for
15 from
16 if
17 import
18 include
19 macro
20 sandbox
21 set
22 spaceless
23 use
24 verbatim
diff --git a/vendor/twig/twig/doc/tags/macro.rst b/vendor/twig/twig/doc/tags/macro.rst
deleted file mode 100644
index 11c115a0..00000000
--- a/vendor/twig/twig/doc/tags/macro.rst
+++ /dev/null
@@ -1,83 +0,0 @@
1``macro``
2=========
3
4Macros are comparable with functions in regular programming languages. They
5are useful to put often used HTML idioms into reusable elements to not repeat
6yourself.
7
8Here is a small example of a macro that renders a form element:
9
10.. code-block:: jinja
11
12 {% macro input(name, value, type, size) %}
13 <input type="{{ type|default('text') }}" name="{{ name }}" value="{{ value|e }}" size="{{ size|default(20) }}" />
14 {% endmacro %}
15
16Macros differs from native PHP functions in a few ways:
17
18* Default argument values are defined by using the ``default`` filter in the
19 macro body;
20
21* Arguments of a macro are always optional.
22
23But as with PHP functions, macros don't have access to the current template
24variables.
25
26.. tip::
27
28 You can pass the whole context as an argument by using the special
29 ``_context`` variable.
30
31Macros can be defined in any template, and need to be "imported" before being
32used (see the documentation for the :doc:`import<../tags/import>` tag for more
33information):
34
35.. code-block:: jinja
36
37 {% import "forms.html" as forms %}
38
39The above ``import`` call imports the "forms.html" file (which can contain only
40macros, or a template and some macros), and import the functions as items of
41the ``forms`` variable.
42
43The macro can then be called at will:
44
45.. code-block:: jinja
46
47 <p>{{ forms.input('username') }}</p>
48 <p>{{ forms.input('password', null, 'password') }}</p>
49
50If macros are defined and used in the same template, you can use the
51special ``_self`` variable to import them:
52
53.. code-block:: jinja
54
55 {% import _self as forms %}
56
57 <p>{{ forms.input('username') }}</p>
58
59.. warning::
60
61 When you define a macro in the template where you are going to use it, you
62 might be tempted to call the macro directly via ``_self.input()`` instead
63 of importing it; even if seems to work, this is just a side-effect of the
64 current implementation and it won't work anymore in Twig 2.x.
65
66When you want to use a macro in another macro from the same file, you need to
67import it locally:
68
69.. code-block:: jinja
70
71 {% macro input(name, value, type, size) %}
72 <input type="{{ type|default('text') }}" name="{{ name }}" value="{{ value|e }}" size="{{ size|default(20) }}" />
73 {% endmacro %}
74
75 {% macro wrapped_input(name, value, type, size) %}
76 {% import _self as forms %}
77
78 <div class="field">
79 {{ forms.input(name, value, type, size) }}
80 </div>
81 {% endmacro %}
82
83.. seealso:: :doc:`from<../tags/from>`, :doc:`import<../tags/import>`
diff --git a/vendor/twig/twig/doc/tags/sandbox.rst b/vendor/twig/twig/doc/tags/sandbox.rst
deleted file mode 100644
index e186726c..00000000
--- a/vendor/twig/twig/doc/tags/sandbox.rst
+++ /dev/null
@@ -1,30 +0,0 @@
1``sandbox``
2===========
3
4The ``sandbox`` tag can be used to enable the sandboxing mode for an included
5template, when sandboxing is not enabled globally for the Twig environment:
6
7.. code-block:: jinja
8
9 {% sandbox %}
10 {% include 'user.html' %}
11 {% endsandbox %}
12
13.. warning::
14
15 The ``sandbox`` tag is only available when the sandbox extension is
16 enabled (see the :doc:`Twig for Developers<../api>` chapter).
17
18.. note::
19
20 The ``sandbox`` tag can only be used to sandbox an include tag and it
21 cannot be used to sandbox a section of a template. The following example
22 won't work:
23
24 .. code-block:: jinja
25
26 {% sandbox %}
27 {% for i in 1..2 %}
28 {{ i }}
29 {% endfor %}
30 {% endsandbox %}
diff --git a/vendor/twig/twig/doc/tags/set.rst b/vendor/twig/twig/doc/tags/set.rst
deleted file mode 100644
index 3eba239a..00000000
--- a/vendor/twig/twig/doc/tags/set.rst
+++ /dev/null
@@ -1,78 +0,0 @@
1``set``
2=======
3
4Inside code blocks you can also assign values to variables. Assignments use
5the ``set`` tag and can have multiple targets.
6
7Here is how you can assign the ``bar`` value to the ``foo`` variable:
8
9.. code-block:: jinja
10
11 {% set foo = 'bar' %}
12
13After the ``set`` call, the ``foo`` variable is available in the template like
14any other ones:
15
16.. code-block:: jinja
17
18 {# displays bar #}
19 {{ foo }}
20
21The assigned value can be any valid :ref:`Twig expressions
22<twig-expressions>`:
23
24.. code-block:: jinja
25
26 {% set foo = [1, 2] %}
27 {% set foo = {'foo': 'bar'} %}
28 {% set foo = 'foo' ~ 'bar' %}
29
30Several variables can be assigned in one block:
31
32.. code-block:: jinja
33
34 {% set foo, bar = 'foo', 'bar' %}
35
36 {# is equivalent to #}
37
38 {% set foo = 'foo' %}
39 {% set bar = 'bar' %}
40
41The ``set`` tag can also be used to 'capture' chunks of text:
42
43.. code-block:: jinja
44
45 {% set foo %}
46 <div id="pagination">
47 ...
48 </div>
49 {% endset %}
50
51.. caution::
52
53 If you enable automatic output escaping, Twig will only consider the
54 content to be safe when capturing chunks of text.
55
56.. note::
57
58 Note that loops are scoped in Twig; therefore a variable declared inside a
59 ``for`` loop is not accessible outside the loop itself:
60
61 .. code-block:: jinja
62
63 {% for item in list %}
64 {% set foo = item %}
65 {% endfor %}
66
67 {# foo is NOT available #}
68
69 If you want to access the variable, just declare it before the loop:
70
71 .. code-block:: jinja
72
73 {% set foo = "" %}
74 {% for item in list %}
75 {% set foo = item %}
76 {% endfor %}
77
78 {# foo is available #}
diff --git a/vendor/twig/twig/doc/tags/spaceless.rst b/vendor/twig/twig/doc/tags/spaceless.rst
deleted file mode 100644
index 12e77b25..00000000
--- a/vendor/twig/twig/doc/tags/spaceless.rst
+++ /dev/null
@@ -1,37 +0,0 @@
1``spaceless``
2=============
3
4Use the ``spaceless`` tag to remove whitespace *between HTML tags*, not
5whitespace within HTML tags or whitespace in plain text:
6
7.. code-block:: jinja
8
9 {% spaceless %}
10 <div>
11 <strong>foo</strong>
12 </div>
13 {% endspaceless %}
14
15 {# output will be <div><strong>foo</strong></div> #}
16
17This tag is not meant to "optimize" the size of the generated HTML content but
18merely to avoid extra whitespace between HTML tags to avoid browser rendering
19quirks under some circumstances.
20
21.. tip::
22
23 If you want to optimize the size of the generated HTML content, gzip
24 compress the output instead.
25
26.. tip::
27
28 If you want to create a tag that actually removes all extra whitespace in
29 an HTML string, be warned that this is not as easy as it seems to be
30 (think of ``textarea`` or ``pre`` tags for instance). Using a third-party
31 library like Tidy is probably a better idea.
32
33.. tip::
34
35 For more information on whitespace control, read the
36 :doc:`dedicated<../templates>` section of the documentation and learn how
37 you can also use the whitespace control modifier on your tags.
diff --git a/vendor/twig/twig/doc/tags/use.rst b/vendor/twig/twig/doc/tags/use.rst
deleted file mode 100644
index 085f9161..00000000
--- a/vendor/twig/twig/doc/tags/use.rst
+++ /dev/null
@@ -1,123 +0,0 @@
1``use``
2=======
3
4.. versionadded:: 1.1
5 Horizontal reuse was added in Twig 1.1.
6
7.. note::
8
9 Horizontal reuse is an advanced Twig feature that is hardly ever needed in
10 regular templates. It is mainly used by projects that need to make
11 template blocks reusable without using inheritance.
12
13Template inheritance is one of the most powerful Twig's feature but it is
14limited to single inheritance; a template can only extend one other template.
15This limitation makes template inheritance simple to understand and easy to
16debug:
17
18.. code-block:: jinja
19
20 {% extends "base.html" %}
21
22 {% block title %}{% endblock %}
23 {% block content %}{% endblock %}
24
25Horizontal reuse is a way to achieve the same goal as multiple inheritance,
26but without the associated complexity:
27
28.. code-block:: jinja
29
30 {% extends "base.html" %}
31
32 {% use "blocks.html" %}
33
34 {% block title %}{% endblock %}
35 {% block content %}{% endblock %}
36
37The ``use`` statement tells Twig to import the blocks defined in
38```blocks.html`` into the current template (it's like macros, but for blocks):
39
40.. code-block:: jinja
41
42 # blocks.html
43 {% block sidebar %}{% endblock %}
44
45In this example, the ``use`` statement imports the ``sidebar`` block into the
46main template. The code is mostly equivalent to the following one (the
47imported blocks are not outputted automatically):
48
49.. code-block:: jinja
50
51 {% extends "base.html" %}
52
53 {% block sidebar %}{% endblock %}
54 {% block title %}{% endblock %}
55 {% block content %}{% endblock %}
56
57.. note::
58
59 The ``use`` tag only imports a template if it does not extend another
60 template, if it does not define macros, and if the body is empty. But it
61 can *use* other templates.
62
63.. note::
64
65 Because ``use`` statements are resolved independently of the context
66 passed to the template, the template reference cannot be an expression.
67
68The main template can also override any imported block. If the template
69already defines the ``sidebar`` block, then the one defined in ``blocks.html``
70is ignored. To avoid name conflicts, you can rename imported blocks:
71
72.. code-block:: jinja
73
74 {% extends "base.html" %}
75
76 {% use "blocks.html" with sidebar as base_sidebar %}
77
78 {% block sidebar %}{% endblock %}
79 {% block title %}{% endblock %}
80 {% block content %}{% endblock %}
81
82.. versionadded:: 1.3
83 The ``parent()`` support was added in Twig 1.3.
84
85The ``parent()`` function automatically determines the correct inheritance
86tree, so it can be used when overriding a block defined in an imported
87template:
88
89.. code-block:: jinja
90
91 {% extends "base.html" %}
92
93 {% use "blocks.html" %}
94
95 {% block sidebar %}
96 {{ parent() }}
97 {% endblock %}
98
99 {% block title %}{% endblock %}
100 {% block content %}{% endblock %}
101
102In this example, ``parent()`` will correctly call the ``sidebar`` block from
103the ``blocks.html`` template.
104
105.. tip::
106
107 In Twig 1.2, renaming allows you to simulate inheritance by calling the
108 "parent" block:
109
110 .. code-block:: jinja
111
112 {% extends "base.html" %}
113
114 {% use "blocks.html" with sidebar as parent_sidebar %}
115
116 {% block sidebar %}
117 {{ block('parent_sidebar') }}
118 {% endblock %}
119
120.. note::
121
122 You can use as many ``use`` statements as you want in any given template.
123 If two imported templates define the same block, the latest one wins.
diff --git a/vendor/twig/twig/doc/tags/verbatim.rst b/vendor/twig/twig/doc/tags/verbatim.rst
deleted file mode 100644
index fe61ca1b..00000000
--- a/vendor/twig/twig/doc/tags/verbatim.rst
+++ /dev/null
@@ -1,24 +0,0 @@
1``verbatim``
2============
3
4.. versionadded:: 1.12
5 The ``verbatim`` tag was added in Twig 1.12 (it was named ``raw`` before).
6
7The ``verbatim`` tag marks sections as being raw text that should not be
8parsed. For example to put Twig syntax as example into a template you can use
9this snippet:
10
11.. code-block:: jinja
12
13 {% verbatim %}
14 <ul>
15 {% for item in seq %}
16 <li>{{ item }}</li>
17 {% endfor %}
18 </ul>
19 {% endverbatim %}
20
21.. note::
22
23 The ``verbatim`` tag works in the exact same way as the old ``raw`` tag,
24 but was renamed to avoid confusion with the ``raw`` filter. \ No newline at end of file
diff --git a/vendor/twig/twig/doc/templates.rst b/vendor/twig/twig/doc/templates.rst
deleted file mode 100644
index 542b8aef..00000000
--- a/vendor/twig/twig/doc/templates.rst
+++ /dev/null
@@ -1,851 +0,0 @@
1Twig for Template Designers
2===========================
3
4This document describes the syntax and semantics of the template engine and
5will be most useful as reference to those creating Twig templates.
6
7Synopsis
8--------
9
10A template is simply a text file. It can generate any text-based format (HTML,
11XML, CSV, LaTeX, etc.). It doesn't have a specific extension, ``.html`` or
12``.xml`` are just fine.
13
14A template contains **variables** or **expressions**, which get replaced with
15values when the template is evaluated, and **tags**, which control the logic
16of the template.
17
18Below is a minimal template that illustrates a few basics. We will cover the
19details later on:
20
21.. code-block:: html+jinja
22
23 <!DOCTYPE html>
24 <html>
25 <head>
26 <title>My Webpage</title>
27 </head>
28 <body>
29 <ul id="navigation">
30 {% for item in navigation %}
31 <li><a href="{{ item.href }}">{{ item.caption }}</a></li>
32 {% endfor %}
33 </ul>
34
35 <h1>My Webpage</h1>
36 {{ a_variable }}
37 </body>
38 </html>
39
40There are two kinds of delimiters: ``{% ... %}`` and ``{{ ... }}``. The first
41one is used to execute statements such as for-loops, the latter prints the
42result of an expression to the template.
43
44IDEs Integration
45----------------
46
47Many IDEs support syntax highlighting and auto-completion for Twig:
48
49* *Textmate* via the `Twig bundle`_
50* *Vim* via the `Jinja syntax plugin`_
51* *Netbeans* via the `Twig syntax plugin`_ (until 7.1, native as of 7.2)
52* *PhpStorm* (native as of 2.1)
53* *Eclipse* via the `Twig plugin`_
54* *Sublime Text* via the `Twig bundle`_
55* *GtkSourceView* via the `Twig language definition`_ (used by gedit and other projects)
56* *Coda* and *SubEthaEdit* via the `Twig syntax mode`_
57* *Coda 2* via the `other Twig syntax mode`_
58* *Komodo* and *Komodo Edit* via the Twig highlight/syntax check mode
59* *Notepad++* via the `Notepad++ Twig Highlighter`_
60* *Emacs* via `web-mode.el`_
61
62Variables
63---------
64
65The application passes variables to the templates you can mess around in the
66template. Variables may have attributes or elements on them you can access
67too. How a variable looks like heavily depends on the application providing
68those.
69
70You can use a dot (``.``) to access attributes of a variable (methods or
71properties of a PHP object, or items of a PHP array), or the so-called
72"subscript" syntax (``[]``):
73
74.. code-block:: jinja
75
76 {{ foo.bar }}
77 {{ foo['bar'] }}
78
79When the attribute contains special characters (like ``-`` that would be
80interpreted as the minus operator), use the ``attribute`` function instead to
81access the variable attribute:
82
83.. code-block:: jinja
84
85 {# equivalent to the non-working foo.data-foo #}
86 {{ attribute(foo, 'data-foo') }}
87
88.. note::
89
90 It's important to know that the curly braces are *not* part of the
91 variable but the print statement. If you access variables inside tags
92 don't put the braces around.
93
94If a variable or attribute does not exist, you will get back a ``null`` value
95when the ``strict_variables`` option is set to ``false``, otherwise Twig will
96throw an error (see :ref:`environment options<environment_options>`).
97
98.. sidebar:: Implementation
99
100 For convenience sake ``foo.bar`` does the following things on the PHP
101 layer:
102
103 * check if ``foo`` is an array and ``bar`` a valid element;
104 * if not, and if ``foo`` is an object, check that ``bar`` is a valid property;
105 * if not, and if ``foo`` is an object, check that ``bar`` is a valid method
106 (even if ``bar`` is the constructor - use ``__construct()`` instead);
107 * if not, and if ``foo`` is an object, check that ``getBar`` is a valid method;
108 * if not, and if ``foo`` is an object, check that ``isBar`` is a valid method;
109 * if not, return a ``null`` value.
110
111 ``foo['bar']`` on the other hand only works with PHP arrays:
112
113 * check if ``foo`` is an array and ``bar`` a valid element;
114 * if not, return a ``null`` value.
115
116.. note::
117
118 If you want to get a dynamic attribute on a variable, use the
119 :doc:`attribute<functions/attribute>` function instead.
120
121Global Variables
122~~~~~~~~~~~~~~~~
123
124The following variables are always available in templates:
125
126* ``_self``: references the current template;
127* ``_context``: references the current context;
128* ``_charset``: references the current charset.
129
130Setting Variables
131~~~~~~~~~~~~~~~~~
132
133You can assign values to variables inside code blocks. Assignments use the
134:doc:`set<tags/set>` tag:
135
136.. code-block:: jinja
137
138 {% set foo = 'foo' %}
139 {% set foo = [1, 2] %}
140 {% set foo = {'foo': 'bar'} %}
141
142Filters
143-------
144
145Variables can be modified by **filters**. Filters are separated from the
146variable by a pipe symbol (``|``) and may have optional arguments in
147parentheses. Multiple filters can be chained. The output of one filter is
148applied to the next.
149
150The following example removes all HTML tags from the ``name`` and title-cases
151it:
152
153.. code-block:: jinja
154
155 {{ name|striptags|title }}
156
157Filters that accept arguments have parentheses around the arguments. This
158example will join a list by commas:
159
160.. code-block:: jinja
161
162 {{ list|join(', ') }}
163
164To apply a filter on a section of code, wrap it with the
165:doc:`filter<tags/filter>` tag:
166
167.. code-block:: jinja
168
169 {% filter upper %}
170 This text becomes uppercase
171 {% endfilter %}
172
173Go to the :doc:`filters<filters/index>` page to learn more about the built-in
174filters.
175
176Functions
177---------
178
179Functions can be called to generate content. Functions are called by their
180name followed by parentheses (``()``) and may have arguments.
181
182For instance, the ``range`` function returns a list containing an arithmetic
183progression of integers:
184
185.. code-block:: jinja
186
187 {% for i in range(0, 3) %}
188 {{ i }},
189 {% endfor %}
190
191Go to the :doc:`functions<functions/index>` page to learn more about the
192built-in functions.
193
194Named Arguments
195---------------
196
197.. versionadded:: 1.12
198 Support for named arguments was added in Twig 1.12.
199
200Arguments for filters and functions can also be passed as *named arguments*:
201
202.. code-block:: jinja
203
204 {% for i in range(low=1, high=10, step=2) %}
205 {{ i }},
206 {% endfor %}
207
208Using named arguments makes your templates more explicit about the meaning of
209the values you pass as arguments:
210
211.. code-block:: jinja
212
213 {{ data|convert_encoding('UTF-8', 'iso-2022-jp') }}
214
215 {# versus #}
216
217 {{ data|convert_encoding(from='iso-2022-jp', to='UTF-8') }}
218
219Named arguments also allow you to skip some arguments for which you don't want
220to change the default value:
221
222.. code-block:: jinja
223
224 {# the first argument is the date format, which defaults to the global date format if null is passed #}
225 {{ "now"|date(null, "Europe/Paris") }}
226
227 {# or skip the format value by using a named argument for the timezone #}
228 {{ "now"|date(timezone="Europe/Paris") }}
229
230You can also use both positional and named arguments in one call, in which
231case positional arguments must always come before named arguments:
232
233.. code-block:: jinja
234
235 {{ "now"|date('d/m/Y H:i', timezone="Europe/Paris") }}
236
237.. tip::
238
239 Each function and filter documentation page has a section where the names
240 of all arguments are listed when supported.
241
242Control Structure
243-----------------
244
245A control structure refers to all those things that control the flow of a
246program - conditionals (i.e. ``if``/``elseif``/``else``), ``for``-loops, as
247well as things like blocks. Control structures appear inside ``{% ... %}``
248blocks.
249
250For example, to display a list of users provided in a variable called
251``users``, use the :doc:`for<tags/for>` tag:
252
253.. code-block:: jinja
254
255 <h1>Members</h1>
256 <ul>
257 {% for user in users %}
258 <li>{{ user.username|e }}</li>
259 {% endfor %}
260 </ul>
261
262The :doc:`if<tags/if>` tag can be used to test an expression:
263
264.. code-block:: jinja
265
266 {% if users|length > 0 %}
267 <ul>
268 {% for user in users %}
269 <li>{{ user.username|e }}</li>
270 {% endfor %}
271 </ul>
272 {% endif %}
273
274Go to the :doc:`tags<tags/index>` page to learn more about the built-in tags.
275
276Comments
277--------
278
279To comment-out part of a line in a template, use the comment syntax ``{# ...
280#}``. This is useful for debugging or to add information for other template
281designers or yourself:
282
283.. code-block:: jinja
284
285 {# note: disabled template because we no longer use this
286 {% for user in users %}
287 ...
288 {% endfor %}
289 #}
290
291Including other Templates
292-------------------------
293
294The :doc:`include<tags/include>` tag is useful to include a template and
295return the rendered content of that template into the current one:
296
297.. code-block:: jinja
298
299 {% include 'sidebar.html' %}
300
301Per default included templates are passed the current context.
302
303The context that is passed to the included template includes variables defined
304in the template:
305
306.. code-block:: jinja
307
308 {% for box in boxes %}
309 {% include "render_box.html" %}
310 {% endfor %}
311
312The included template ``render_box.html`` is able to access ``box``.
313
314The filename of the template depends on the template loader. For instance, the
315``Twig_Loader_Filesystem`` allows you to access other templates by giving the
316filename. You can access templates in subdirectories with a slash:
317
318.. code-block:: jinja
319
320 {% include "sections/articles/sidebar.html" %}
321
322This behavior depends on the application embedding Twig.
323
324Template Inheritance
325--------------------
326
327The most powerful part of Twig is template inheritance. Template inheritance
328allows you to build a base "skeleton" template that contains all the common
329elements of your site and defines **blocks** that child templates can
330override.
331
332Sounds complicated but is very basic. It's easier to understand it by
333starting with an example.
334
335Let's define a base template, ``base.html``, which defines a simple HTML
336skeleton document that you might use for a simple two-column page:
337
338.. code-block:: html+jinja
339
340 <!DOCTYPE html>
341 <html>
342 <head>
343 {% block head %}
344 <link rel="stylesheet" href="style.css" />
345 <title>{% block title %}{% endblock %} - My Webpage</title>
346 {% endblock %}
347 </head>
348 <body>
349 <div id="content">{% block content %}{% endblock %}</div>
350 <div id="footer">
351 {% block footer %}
352 &copy; Copyright 2011 by <a href="http://domain.invalid/">you</a>.
353 {% endblock %}
354 </div>
355 </body>
356 </html>
357
358In this example, the :doc:`block<tags/block>` tags define four blocks that
359child templates can fill in. All the ``block`` tag does is to tell the
360template engine that a child template may override those portions of the
361template.
362
363A child template might look like this:
364
365.. code-block:: jinja
366
367 {% extends "base.html" %}
368
369 {% block title %}Index{% endblock %}
370 {% block head %}
371 {{ parent() }}
372 <style type="text/css">
373 .important { color: #336699; }
374 </style>
375 {% endblock %}
376 {% block content %}
377 <h1>Index</h1>
378 <p class="important">
379 Welcome to my awesome homepage.
380 </p>
381 {% endblock %}
382
383The :doc:`extends<tags/extends>` tag is the key here. It tells the template
384engine that this template "extends" another template. When the template system
385evaluates this template, first it locates the parent. The extends tag should
386be the first tag in the template.
387
388Note that since the child template doesn't define the ``footer`` block, the
389value from the parent template is used instead.
390
391It's possible to render the contents of the parent block by using the
392:doc:`parent<functions/parent>` function. This gives back the results of the
393parent block:
394
395.. code-block:: jinja
396
397 {% block sidebar %}
398 <h3>Table Of Contents</h3>
399 ...
400 {{ parent() }}
401 {% endblock %}
402
403.. tip::
404
405 The documentation page for the :doc:`extends<tags/extends>` tag describes
406 more advanced features like block nesting, scope, dynamic inheritance, and
407 conditional inheritance.
408
409.. note::
410
411 Twig also supports multiple inheritance with the so called horizontal reuse
412 with the help of the :doc:`use<tags/use>` tag. This is an advanced feature
413 hardly ever needed in regular templates.
414
415HTML Escaping
416-------------
417
418When generating HTML from templates, there's always a risk that a variable
419will include characters that affect the resulting HTML. There are two
420approaches: manually escaping each variable or automatically escaping
421everything by default.
422
423Twig supports both, automatic escaping is enabled by default.
424
425.. note::
426
427 Automatic escaping is only supported if the *escaper* extension has been
428 enabled (which is the default).
429
430Working with Manual Escaping
431~~~~~~~~~~~~~~~~~~~~~~~~~~~~
432
433If manual escaping is enabled, it is **your** responsibility to escape
434variables if needed. What to escape? Any variable you don't trust.
435
436Escaping works by piping the variable through the
437:doc:`escape<filters/escape>` or ``e`` filter:
438
439.. code-block:: jinja
440
441 {{ user.username|e }}
442
443By default, the ``escape`` filter uses the ``html`` strategy, but depending on
444the escaping context, you might want to explicitly use any other available
445strategies:
446
447.. code-block:: jinja
448
449 {{ user.username|e('js') }}
450 {{ user.username|e('css') }}
451 {{ user.username|e('url') }}
452 {{ user.username|e('html_attr') }}
453
454Working with Automatic Escaping
455~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
456
457Whether automatic escaping is enabled or not, you can mark a section of a
458template to be escaped or not by using the :doc:`autoescape<tags/autoescape>`
459tag:
460
461.. code-block:: jinja
462
463 {% autoescape %}
464 Everything will be automatically escaped in this block (using the HTML strategy)
465 {% endautoescape %}
466
467By default, auto-escaping uses the ``html`` escaping strategy. If you output
468variables in other contexts, you need to explicitly escape them with the
469appropriate escaping strategy:
470
471.. code-block:: jinja
472
473 {% autoescape 'js' %}
474 Everything will be automatically escaped in this block (using the JS strategy)
475 {% endautoescape %}
476
477Escaping
478--------
479
480It is sometimes desirable or even necessary to have Twig ignore parts it would
481otherwise handle as variables or blocks. For example if the default syntax is
482used and you want to use ``{{`` as raw string in the template and not start a
483variable you have to use a trick.
484
485The easiest way is to output the variable delimiter (``{{``) by using a variable
486expression:
487
488.. code-block:: jinja
489
490 {{ '{{' }}
491
492For bigger sections it makes sense to mark a block
493:doc:`verbatim<tags/verbatim>`.
494
495Macros
496------
497
498.. versionadded:: 1.12
499 Support for default argument values was added in Twig 1.12.
500
501Macros are comparable with functions in regular programming languages. They
502are useful to reuse often used HTML fragments to not repeat yourself.
503
504A macro is defined via the :doc:`macro<tags/macro>` tag. Here is a small example
505(subsequently called ``forms.html``) of a macro that renders a form element:
506
507.. code-block:: jinja
508
509 {% macro input(name, value, type, size) %}
510 <input type="{{ type|default('text') }}" name="{{ name }}" value="{{ value|e }}" size="{{ size|default(20) }}" />
511 {% endmacro %}
512
513Macros can be defined in any template, and need to be "imported" via the
514:doc:`import<tags/import>` tag before being used:
515
516.. code-block:: jinja
517
518 {% import "forms.html" as forms %}
519
520 <p>{{ forms.input('username') }}</p>
521
522Alternatively, you can import individual macro names from a template into the
523current namespace via the :doc:`from<tags/from>` tag and optionally alias them:
524
525.. code-block:: jinja
526
527 {% from 'forms.html' import input as input_field %}
528
529 <dl>
530 <dt>Username</dt>
531 <dd>{{ input_field('username') }}</dd>
532 <dt>Password</dt>
533 <dd>{{ input_field('password', '', 'password') }}</dd>
534 </dl>
535
536A default value can also be defined for macro arguments when not provided in a
537macro call:
538
539.. code-block:: jinja
540
541 {% macro input(name, value = "", type = "text", size = 20) %}
542 <input type="{{ type }}" name="{{ name }}" value="{{ value|e }}" size="{{ size }}" />
543 {% endmacro %}
544
545.. _twig-expressions:
546
547Expressions
548-----------
549
550Twig allows expressions everywhere. These work very similar to regular PHP and
551even if you're not working with PHP you should feel comfortable with it.
552
553.. note::
554
555 The operator precedence is as follows, with the lowest-precedence
556 operators listed first: ``b-and``, ``b-xor``, ``b-or``, ``or``, ``and``,
557 ``==``, ``!=``, ``<``, ``>``, ``>=``, ``<=``, ``in``, ``..``, ``+``,
558 ``-``, ``~``, ``*``, ``/``, ``//``, ``%``, ``is``, ``**``, ``|``, ``[]``,
559 and ``.``:
560
561 .. code-block:: jinja
562
563 {% set greeting = 'Hello' %}
564 {% set name = 'Fabien' %}
565
566 {{ greeting ~ name|lower }} {# Hello fabien #}
567
568 {# use parenthesis to change precedence #}
569 {{ (greeting ~ name)|lower }} {# hello fabien #}
570
571Literals
572~~~~~~~~
573
574.. versionadded:: 1.5
575 Support for hash keys as names and expressions was added in Twig 1.5.
576
577The simplest form of expressions are literals. Literals are representations
578for PHP types such as strings, numbers, and arrays. The following literals
579exist:
580
581* ``"Hello World"``: Everything between two double or single quotes is a
582 string. They are useful whenever you need a string in the template (for
583 example as arguments to function calls, filters or just to extend or include
584 a template). A string can contain a delimiter if it is preceded by a
585 backslash (``\``) -- like in ``'It\'s good'``.
586
587* ``42`` / ``42.23``: Integers and floating point numbers are created by just
588 writing the number down. If a dot is present the number is a float,
589 otherwise an integer.
590
591* ``["foo", "bar"]``: Arrays are defined by a sequence of expressions
592 separated by a comma (``,``) and wrapped with squared brackets (``[]``).
593
594* ``{"foo": "bar"}``: Hashes are defined by a list of keys and values
595 separated by a comma (``,``) and wrapped with curly braces (``{}``):
596
597 .. code-block:: jinja
598
599 {# keys as string #}
600 { 'foo': 'foo', 'bar': 'bar' }
601
602 {# keys as names (equivalent to the previous hash) -- as of Twig 1.5 #}
603 { foo: 'foo', bar: 'bar' }
604
605 {# keys as integer #}
606 { 2: 'foo', 4: 'bar' }
607
608 {# keys as expressions (the expression must be enclosed into parentheses) -- as of Twig 1.5 #}
609 { (1 + 1): 'foo', (a ~ 'b'): 'bar' }
610
611* ``true`` / ``false``: ``true`` represents the true value, ``false``
612 represents the false value.
613
614* ``null``: ``null`` represents no specific value. This is the value returned
615 when a variable does not exist. ``none`` is an alias for ``null``.
616
617Arrays and hashes can be nested:
618
619.. code-block:: jinja
620
621 {% set foo = [1, {"foo": "bar"}] %}
622
623.. tip::
624
625 Using double-quoted or single-quoted strings has no impact on performance
626 but string interpolation is only supported in double-quoted strings.
627
628Math
629~~~~
630
631Twig allows you to calculate with values. This is rarely useful in templates
632but exists for completeness' sake. The following operators are supported:
633
634* ``+``: Adds two objects together (the operands are casted to numbers). ``{{
635 1 + 1 }}`` is ``2``.
636
637* ``-``: Subtracts the second number from the first one. ``{{ 3 - 2 }}`` is
638 ``1``.
639
640* ``/``: Divides two numbers. The returned value will be a floating point
641 number. ``{{ 1 / 2 }}`` is ``{{ 0.5 }}``.
642
643* ``%``: Calculates the remainder of an integer division. ``{{ 11 % 7 }}`` is
644 ``4``.
645
646* ``//``: Divides two numbers and returns the truncated integer result. ``{{
647 20 // 7 }}`` is ``2``.
648
649* ``*``: Multiplies the left operand with the right one. ``{{ 2 * 2 }}`` would
650 return ``4``.
651
652* ``**``: Raises the left operand to the power of the right operand. ``{{ 2 **
653 3 }}`` would return ``8``.
654
655Logic
656~~~~~
657
658You can combine multiple expressions with the following operators:
659
660* ``and``: Returns true if the left and the right operands are both true.
661
662* ``or``: Returns true if the left or the right operand is true.
663
664* ``not``: Negates a statement.
665
666* ``(expr)``: Groups an expression.
667
668.. note::
669
670 Twig also support bitwise operators (``b-and``, ``b-xor``, and ``b-or``).
671
672Comparisons
673~~~~~~~~~~~
674
675The following comparison operators are supported in any expression: ``==``,
676``!=``, ``<``, ``>``, ``>=``, and ``<=``.
677
678Containment Operator
679~~~~~~~~~~~~~~~~~~~~
680
681The ``in`` operator performs containment test.
682
683It returns ``true`` if the left operand is contained in the right:
684
685.. code-block:: jinja
686
687 {# returns true #}
688
689 {{ 1 in [1, 2, 3] }}
690
691 {{ 'cd' in 'abcde' }}
692
693.. tip::
694
695 You can use this filter to perform a containment test on strings, arrays,
696 or objects implementing the ``Traversable`` interface.
697
698To perform a negative test, use the ``not in`` operator:
699
700.. code-block:: jinja
701
702 {% if 1 not in [1, 2, 3] %}
703
704 {# is equivalent to #}
705 {% if not (1 in [1, 2, 3]) %}
706
707Test Operator
708~~~~~~~~~~~~~
709
710The ``is`` operator performs tests. Tests can be used to test a variable against
711a common expression. The right operand is name of the test:
712
713.. code-block:: jinja
714
715 {# find out if a variable is odd #}
716
717 {{ name is odd }}
718
719Tests can accept arguments too:
720
721.. code-block:: jinja
722
723 {% if loop.index is divisibleby(3) %}
724
725Tests can be negated by using the ``is not`` operator:
726
727.. code-block:: jinja
728
729 {% if loop.index is not divisibleby(3) %}
730
731 {# is equivalent to #}
732 {% if not (loop.index is divisibleby(3)) %}
733
734Go to the :doc:`tests<tests/index>` page to learn more about the built-in
735tests.
736
737Other Operators
738~~~~~~~~~~~~~~~
739
740.. versionadded:: 1.12.0
741 Support for the extended ternary operator was added in Twig 1.12.0.
742
743The following operators are very useful but don't fit into any of the other
744categories:
745
746* ``..``: Creates a sequence based on the operand before and after the
747 operator (this is just syntactic sugar for the :doc:`range<functions/range>`
748 function).
749
750* ``|``: Applies a filter.
751
752* ``~``: Converts all operands into strings and concatenates them. ``{{ "Hello
753 " ~ name ~ "!" }}`` would return (assuming ``name`` is ``'John'``) ``Hello
754 John!``.
755
756* ``.``, ``[]``: Gets an attribute of an object.
757
758* ``?:``: The ternary operator:
759
760 .. code-block:: jinja
761
762 {{ foo ? 'yes' : 'no' }}
763
764 {# as of Twig 1.12.0 #}
765 {{ foo ?: 'no' }} == {{ foo ? foo : 'no' }}
766 {{ foo ? 'yes' }} == {{ foo ? 'yes' : '' }}
767
768String Interpolation
769~~~~~~~~~~~~~~~~~~~~
770
771.. versionadded:: 1.5
772 String interpolation was added in Twig 1.5.
773
774String interpolation (`#{expression}`) allows any valid expression to appear
775within a *double-quoted string*. The result of evaluating that expression is
776inserted into the string:
777
778.. code-block:: jinja
779
780 {{ "foo #{bar} baz" }}
781 {{ "foo #{1 + 2} baz" }}
782
783Whitespace Control
784------------------
785
786.. versionadded:: 1.1
787 Tag level whitespace control was added in Twig 1.1.
788
789The first newline after a template tag is removed automatically (like in PHP.)
790Whitespace is not further modified by the template engine, so each whitespace
791(spaces, tabs, newlines etc.) is returned unchanged.
792
793Use the ``spaceless`` tag to remove whitespace *between HTML tags*:
794
795.. code-block:: jinja
796
797 {% spaceless %}
798 <div>
799 <strong>foo bar</strong>
800 </div>
801 {% endspaceless %}
802
803 {# output will be <div><strong>foo bar</strong></div> #}
804
805In addition to the spaceless tag you can also control whitespace on a per tag
806level. By using the whitespace control modifier on your tags, you can trim
807leading and or trailing whitespace:
808
809.. code-block:: jinja
810
811 {% set value = 'no spaces' %}
812 {#- No leading/trailing whitespace -#}
813 {%- if true -%}
814 {{- value -}}
815 {%- endif -%}
816
817 {# output 'no spaces' #}
818
819The above sample shows the default whitespace control modifier, and how you can
820use it to remove whitespace around tags. Trimming space will consume all whitespace
821for that side of the tag. It is possible to use whitespace trimming on one side
822of a tag:
823
824.. code-block:: jinja
825
826 {% set value = 'no spaces' %}
827 <li> {{- value }} </li>
828
829 {# outputs '<li>no spaces </li>' #}
830
831Extensions
832----------
833
834Twig can be easily extended.
835
836If you are looking for new tags, filters, or functions, have a look at the Twig official
837`extension repository`_.
838
839If you want to create your own, read the :ref:`Creating an
840Extension<creating_extensions>` chapter.
841
842.. _`Twig bundle`: https://github.com/Anomareh/PHP-Twig.tmbundle
843.. _`Jinja syntax plugin`: http://jinja.pocoo.org/2/documentation/integration
844.. _`Twig syntax plugin`: http://plugins.netbeans.org/plugin/37069/php-twig
845.. _`Twig plugin`: https://github.com/pulse00/Twig-Eclipse-Plugin
846.. _`Twig language definition`: https://github.com/gabrielcorpse/gedit-twig-template-language
847.. _`extension repository`: http://github.com/fabpot/Twig-extensions
848.. _`Twig syntax mode`: https://github.com/bobthecow/Twig-HTML.mode
849.. _`other Twig syntax mode`: https://github.com/muxx/Twig-HTML.mode
850.. _`Notepad++ Twig Highlighter`: https://github.com/Banane9/notepadplusplus-twig
851.. _`web-mode.el`: http://web-mode.org/
diff --git a/vendor/twig/twig/doc/tests/constant.rst b/vendor/twig/twig/doc/tests/constant.rst
deleted file mode 100644
index 8d0724a8..00000000
--- a/vendor/twig/twig/doc/tests/constant.rst
+++ /dev/null
@@ -1,22 +0,0 @@
1``constant``
2============
3
4.. versionadded: 1.13.1
5 constant now accepts object instances as the second argument.
6
7``constant`` checks if a variable has the exact same value as a constant. You
8can use either global constants or class constants:
9
10.. code-block:: jinja
11
12 {% if post.status is constant('Post::PUBLISHED') %}
13 the status attribute is exactly the same as Post::PUBLISHED
14 {% endif %}
15
16You can test constants from object instances as well:
17
18.. code-block:: jinja
19
20 {% if post.status is constant('PUBLISHED', post) %}
21 the status attribute is exactly the same as Post::PUBLISHED
22 {% endif %}
diff --git a/vendor/twig/twig/doc/tests/defined.rst b/vendor/twig/twig/doc/tests/defined.rst
deleted file mode 100644
index 702ce725..00000000
--- a/vendor/twig/twig/doc/tests/defined.rst
+++ /dev/null
@@ -1,30 +0,0 @@
1``defined``
2===========
3
4``defined`` checks if a variable is defined in the current context. This is very
5useful if you use the ``strict_variables`` option:
6
7.. code-block:: jinja
8
9 {# defined works with variable names #}
10 {% if foo is defined %}
11 ...
12 {% endif %}
13
14 {# and attributes on variables names #}
15 {% if foo.bar is defined %}
16 ...
17 {% endif %}
18
19 {% if foo['bar'] is defined %}
20 ...
21 {% endif %}
22
23When using the ``defined`` test on an expression that uses variables in some
24method calls, be sure that they are all defined first:
25
26.. code-block:: jinja
27
28 {% if var is defined and foo.method(var) is defined %}
29 ...
30 {% endif %}
diff --git a/vendor/twig/twig/doc/tests/divisibleby.rst b/vendor/twig/twig/doc/tests/divisibleby.rst
deleted file mode 100644
index 9b0b9644..00000000
--- a/vendor/twig/twig/doc/tests/divisibleby.rst
+++ /dev/null
@@ -1,10 +0,0 @@
1``divisibleby``
2===============
3
4``divisibleby`` checks if a variable is divisible by a number:
5
6.. code-block:: jinja
7
8 {% if loop.index is divisibleby(3) %}
9 ...
10 {% endif %}
diff --git a/vendor/twig/twig/doc/tests/empty.rst b/vendor/twig/twig/doc/tests/empty.rst
deleted file mode 100644
index e5b55999..00000000
--- a/vendor/twig/twig/doc/tests/empty.rst
+++ /dev/null
@@ -1,11 +0,0 @@
1``empty``
2=========
3
4``empty`` checks if a variable is empty:
5
6.. code-block:: jinja
7
8 {# evaluates to true if the foo variable is null, false, an empty array, or the empty string #}
9 {% if foo is empty %}
10 ...
11 {% endif %}
diff --git a/vendor/twig/twig/doc/tests/even.rst b/vendor/twig/twig/doc/tests/even.rst
deleted file mode 100644
index 6ab5cc39..00000000
--- a/vendor/twig/twig/doc/tests/even.rst
+++ /dev/null
@@ -1,10 +0,0 @@
1``even``
2========
3
4``even`` returns ``true`` if the given number is even:
5
6.. code-block:: jinja
7
8 {{ var is even }}
9
10.. seealso:: :doc:`odd<../tests/odd>`
diff --git a/vendor/twig/twig/doc/tests/index.rst b/vendor/twig/twig/doc/tests/index.rst
deleted file mode 100644
index c63208ee..00000000
--- a/vendor/twig/twig/doc/tests/index.rst
+++ /dev/null
@@ -1,15 +0,0 @@
1Tests
2=====
3
4.. toctree::
5 :maxdepth: 1
6
7 constant
8 defined
9 divisibleby
10 empty
11 even
12 iterable
13 null
14 odd
15 sameas
diff --git a/vendor/twig/twig/doc/tests/iterable.rst b/vendor/twig/twig/doc/tests/iterable.rst
deleted file mode 100644
index 89a172f7..00000000
--- a/vendor/twig/twig/doc/tests/iterable.rst
+++ /dev/null
@@ -1,19 +0,0 @@
1``iterable``
2============
3
4.. versionadded:: 1.7
5 The iterable test was added in Twig 1.7.
6
7``iterable`` checks if a variable is an array or a traversable object:
8
9.. code-block:: jinja
10
11 {# evaluates to true if the foo variable is iterable #}
12 {% if users is iterable %}
13 {% for user in users %}
14 Hello {{ user }}!
15 {% endfor %}
16 {% else %}
17 {# users is probably a string #}
18 Hello {{ users }}!
19 {% endif %}
diff --git a/vendor/twig/twig/doc/tests/null.rst b/vendor/twig/twig/doc/tests/null.rst
deleted file mode 100644
index 44eec62e..00000000
--- a/vendor/twig/twig/doc/tests/null.rst
+++ /dev/null
@@ -1,12 +0,0 @@
1``null``
2========
3
4``null`` returns ``true`` if the variable is ``null``:
5
6.. code-block:: jinja
7
8 {{ var is null }}
9
10.. note::
11
12 ``none`` is an alias for ``null``.
diff --git a/vendor/twig/twig/doc/tests/odd.rst b/vendor/twig/twig/doc/tests/odd.rst
deleted file mode 100644
index 9eece777..00000000
--- a/vendor/twig/twig/doc/tests/odd.rst
+++ /dev/null
@@ -1,10 +0,0 @@
1``odd``
2=======
3
4``odd`` returns ``true`` if the given number is odd:
5
6.. code-block:: jinja
7
8 {{ var is odd }}
9
10.. seealso:: :doc:`even<../tests/even>`
diff --git a/vendor/twig/twig/doc/tests/sameas.rst b/vendor/twig/twig/doc/tests/sameas.rst
deleted file mode 100644
index efb15c35..00000000
--- a/vendor/twig/twig/doc/tests/sameas.rst
+++ /dev/null
@@ -1,11 +0,0 @@
1``sameas``
2==========
3
4``sameas`` checks if a variable points to the same memory address than another
5variable:
6
7.. code-block:: jinja
8
9 {% if foo.attribute is sameas(false) %}
10 the foo attribute really is the ``false`` PHP value
11 {% endif %}