Commit Graph

54 Commits

Author SHA1 Message Date
Fabien Potencier 0446296d5f fixed more short array notations 2019-01-08 11:56:16 +01:00
Fabien Potencier 5c55243d71 switched to use PHP short array notation for Twig's code 2019-01-08 09:35:30 +01:00
Fabien Potencier e231aa539f renamed Twig_Node::getName() to Twig_Node::getTemplateName() 2016-10-19 14:59:16 -07:00
Fabien Potencier 7082738cbf optimized generated code 2016-10-17 15:37:49 -07:00
Fabien Potencier 7598f27e6d deprecated Twig_Template::getSource() in favor of Twig_Template::getSourceContext() 2016-10-17 15:30:12 -07:00
Fabien Potencier d03297ed52 deprecated Twig_Node::getFilename() in favor of Twig_Node::getName() 2016-10-17 15:04:06 -07:00
Fabien Potencier 6c76583e23 added Twig_Source to hold information about the original template 2016-10-17 13:33:17 -07:00
Fabien Potencier b55d907c94 changed the way we store template source in template classes 2016-09-20 10:55:24 -07:00
Sam Mousa 17e0caa91a Fixed all deprecation notices by using 2016-07-28 16:56:02 -04:00
Remi Collet ee5e25eb46 fix BC, revert to pre 1.23 behavior, and make use of pattern an option 2015-11-02 15:13:46 +01:00
Tobias Schultze f379e8141c fix template class name generation to prevent possible collisions and one inode per file 2015-10-03 20:59:41 +02:00
Fabien Potencier 550a384412 added enabled extension names in the generated template class names 2015-09-12 14:43:01 +02:00
Possum 2030482e4d clean ups 2015-04-24 17:14:22 +02:00
Fabien Potencier 3779435d62 deprecated the String loader 2015-03-02 15:45:22 +01:00
Fabien Potencier 651613c32c reduced the number of times error information should be guessed 2015-02-27 16:01:28 +01:00
Fabien Potencier 4ba0789614 removed @covers annotations 2014-11-20 08:47:31 +01:00
Martin Hasoň 8f617dc6b5 Fixed guessing a template info for the Twig_Error_Loader exception 2014-10-20 11:57:38 +02:00
Fabien Potencier 74586e9f08 Revert "merged branch hason/macros (PR #1139)"
This reverts commit 03926034c4, reversing
changes made to 730aa25bed.

Conflicts:
	CHANGELOG
	doc/tags/macro.rst
	doc/templates.rst
	lib/Twig/ExpressionParser.php
2013-10-02 21:50:59 +02:00
Fabien Potencier 9a01db60e8 replaced usage of md5/sha1 by sha256 2013-08-04 15:12:06 +02:00
Martin Hasoň 9e96837827 Refactored parsing of macros 2013-07-16 10:43:52 +02:00
Charles 7c5854bba9 Fix twig error lineno off by 2 2012-11-08 10:22:28 +01:00
Fabien Potencier a009821dd3 fixed CS 2012-11-03 08:27:41 +01:00
Fabien Potencier 3031fe6b95 changed Node instances line numbers from 0 to 1 in unit tests to better reflect what really happens when using Twig 2012-10-19 08:48:03 +02:00
Drak 36372c61d3 Made node tests reusable 2012-09-18 10:13:12 +01:00
Fabien Potencier 2fa8224be4 added the inline tag 2012-04-23 19:39:43 +02:00
Fabien Potencier 3398b38cf0 fixed a regression when a template only extends another one without defining any blocks (closes #683) 2012-04-03 19:13:30 +02:00
Fabien Potencier 1e9a1ae0be optimized parent template creation when the template does not use dynamic inheritance 2012-03-31 15:21:57 +02:00
Fabien Potencier 49ee8d6e41 made the strategy used to guess the real template file name and line number in exception messages much faster and more accurate (refs #647) 2012-03-18 03:33:46 +01:00
Fabien Potencier 3689745d35 moved some common compiled code to Twig_Template 2011-12-08 19:14:07 +01:00
Fabien Potencier bd5687ee10 made an optimization by removing array_merge usage 2011-10-08 14:27:18 +02:00
Fabien Potencier e0cd76614f fixed hardcoded name escaping 2011-09-30 17:10:56 +02:00
Fabien Potencier 56f82db1a1 allowed empty templates to be used as traits 2011-09-22 11:51:48 +02:00
Fabien Potencier 4402ee2c1d added support for an array of templates to the "extends" tag 2011-08-27 20:34:02 +02:00
Fabien Potencier 26d8aff746 refactored code 2011-08-06 10:44:55 +02:00
Fabien Potencier c201137f21 moved Template::getParent() logic to the base class 2011-08-06 09:09:18 +02:00
Fabien Potencier 6e97162de4 merged branch netzhuffle/master (PR #396)
Commits
-------

7b154d6 Switched a tab to four spaces
29d3cb2 Added testcase for #395
4fc7a8d Merge remote-tracking branch 'upstream/master'
c890cf2 Fixed existing tests
9822ac4 Changed Module.php to pass existing tests
fab8c72 fixed issue #395

Discussion
----------

Fix for issue #395

Fix for #395
I hope you can use it.

---------------------------------------------------------------------------

by fabpot at 2011/07/25 00:07:50 -0700

Can you add some unit tests?

---------------------------------------------------------------------------

by netzhuffle at 2011/07/25 13:57:55 -0700

Here you are.
2011-07-26 17:30:32 +02:00
Fabien Potencier 7f5390a6a7 fixed compilation of templates when the body of a child template is not empty 2011-07-26 08:02:51 +02:00
Jannis Grimm c890cf2b64 Fixed existing tests 2011-07-25 22:29:47 +02:00
Fabien Potencier 221eb48ea8 added support for traits (experimental)
Traits are "special" templates that define blocks that you can "include" in
other templates.

Let's take an example:

    {# 'foo' template defines the 'foo' block #}
    {% block 'foo' %}
        FOO
    {% endblock %}

    {# 'main' template defines the 'bar' block and include the 'foo' block from the 'foo' template #}
    {% extends 'base' %}

    {% use 'foo' %}

    {% block 'bar' %}
        BAR
    {% endblock %}

In the previous example, the 'main' template use the 'foo' one. It means that
the 'foo' block defined in the 'foo' template is available as if it were
defined in the 'main' template.

You can use as many 'use' statements as you want in a template:

    {% extends 'base' %}

    {% use 'foo' %}
    {% use 'bar' %}
    {% use 'foobar' %}

If two templates define the same block, the latest one wins. The template can
also overrides any block.

The 'use' tag also supports "dynamic" names:

    {% set foo = 'foo' %}

    {% use foo %}

The 'use' tag only imports a template if it does not extend another template,
if it does not define macros, and if the body is empty. But it can 'use' other
templates:

    {# 'foo' template #}
    {% block 'foo' %}
        FOO
    {% endblock %}

    {# 'bar' template #}
    {% use 'foo' %}

    {% block 'bar' %}
        BAR
    {% endblock %}

    {# 'main' template #}
    {% extends 'base' %}

    {% use 'bar' %}

In this example, the 'main' template has access to both 'foo' and 'bar'.

Traits are mainly useful when you consider blocks as reusable "functions";
like we do in Symfony2 forms or if you use Twig for code generation.
2011-04-28 16:22:09 +02:00
Fabien Potencier 9c17a51fe4 Merge remote branch 'hason/template'
* hason/template:
  deleted abstract method doDisplay (maintain BC)
  added possibility to customize "display" in the base template class
2011-04-12 07:53:48 +02:00
Fabien Potencier 529721d773 fixed wrong usage of loadTemplate() 2011-02-04 12:53:34 +01:00
Martin Hason f93a857126 added possibility to customize "display" in the base template class 2011-02-02 14:41:20 +01:00
Fabien Potencier ac9e4eec15 fixed the ternary operator 2011-01-10 19:07:04 +01:00
Fabien Potencier afa47bd9a4 added global variables 2010-12-19 19:50:03 +01:00
Fabien Potencier c66ab82354 made error message for strict variables more useful 2010-11-27 11:15:27 +01:00
Fabien Potencier 29b020eb2f changed the way to access nodes and attributes from a node
Before:
  Nodes were accessed via node properties ($node->body)
  Attributes were accessed via node array access ($node['name'])

After:
  Nodes are accessed via getNode(), setNode(), ... ($node->getNode('body'))
  Attributes are accessed via getAttribute(), setAttribute(), ... ($node->getAttribute('name'))

The change was necessary because of side-effects. This is one more time the
demonstration that being explicit is always better than magic ;)
2010-10-02 08:29:25 +02:00
Fabien Potencier 15f3276676 changed the implementation of template inheritance 2010-10-01 14:17:16 +02:00
Fabien Potencier 277c4430c6 fixed template cloning problem with inheritance 2010-07-12 17:48:10 +02:00
Fabien Potencier 478fe2ed18 fixed inheritance 2010-06-29 16:28:02 +02:00
Fabien Potencier 57f2853320 removed getName() method in Twig_Template 2010-06-12 15:43:36 +02:00