Commit Graph

492 Commits

Author SHA1 Message Date
nikic b0a94baebd Fix regression in defined test for GetAttr. Fixes #319 2011-05-18 08:08:32 +02:00
Fabien Potencier 654468ff5d simplified code 2011-05-10 07:21:09 +02:00
Fabien Potencier 48f427ebd3 added a test for the raw tag 2011-05-09 17:47:21 +02:00
Fabien Potencier 93425b32cb fixed parsing problem when a large chunk of text is enclosed in a raw tag
This is a quick and ugly fix... This should be refactored later on
2011-05-09 17:35:11 +02:00
Fabien Potencier d88e7ca244 fixed CS 2011-05-09 16:41:39 +02:00
Fabien Potencier 17f814223b updated email address 2011-04-29 17:18:51 +02:00
Fabien Potencier 109ce30288 made a small speed optimization when using auto-escaping 2011-04-29 15:23:00 +02:00
Fabien Potencier e4d457e55c updated version 2011-04-29 12:45:10 +02:00
Joseph Bielawski e307cfab06 Compiler.php - CS fix 2011-04-29 02:59:03 -07:00
Joseph Bielawski a0709beee6 TokenParserBroker.php - CS fix 2011-04-29 02:57:54 -07:00
Joseph Bielawski fa93043bf3 Parser.php - CS fix 2011-04-29 02:56:34 -07:00
Joseph Bielawski c716b99278 Lexer.php - CS fix 2011-04-29 02:54:59 -07:00
Joseph Bielawski 68a39159b0 Environment.php - CS fix 2011-04-29 02:46:23 -07:00
Joseph Bielawski 475ec2db03 TokenParserBroker.php - CS fix 2011-04-29 02:42:36 -07:00
Joseph Bielawski 448106fa04 DRY optimization 2011-04-29 01:34:13 -07:00
Fabien Potencier 3930ba0f4e added some tests for the use tag 2011-04-29 09:43:23 +02:00
Fabien Potencier 4a7aaad594 added support for block renaming when importing traits
{% use 'TwigBundle:Form:div_layout.html.twig' with text_widget as foo_text_widget %}
2011-04-29 00:07:00 +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
nikic 17af31b5b4 Use a type strict null check for GetAttr defined tests. Fixes #305 2011-04-28 13:17:49 +02:00
lenar 04fcc0ca76 fixes performance regression
The regression was introduced by 1e09c7b660.
2011-04-28 11:27:40 +03:00
Joseph Bielawski 2f5e0cacd4 Simplify fix. 2011-04-27 08:50:08 -07:00
Joseph Bielawski 36143a6b6c Fix for issue #307 2011-04-27 07:57:39 -07:00
Fabien Potencier 1e09c7b660 added template file information when an error occurs during compilation 2011-04-22 16:08:43 +02:00
Fabien Potencier 9d88081c94 tweaked Twig_Error to keep the passed line or template when passed in the constructor and findTemplateInfo() was not able to guess it better 2011-04-22 16:06:50 +02:00
Fabien Potencier 76205f1eaa added null as an alias to none and made TRUE, FALSE, and NONE equivalent to true, false, and none 2011-04-14 07:35:58 +02:00
Fabien Potencier 385dc39689 Merge remote branch 'markstory/whitespace'
* markstory/whitespace:
  Updating documentation for whitespace trim tags.
  Making trim tags consume all whitespace, both horizontal and vertical.
  Adding additional test suggested by nikic.
  Making a capturing group non capturing, as the group isn't used.
  Moving newline trimming into the regexp used to match end of tags.
  Applying changes suggested by nikic to simplify how end of comments are processed.
  Fixing some whitespace.
  Fixing typo.
  Adding a bit of documentation for whitespace trimming.
  Adding whitespace trimming support to other tag types (comments, variables) Refactoring how whitespace trimming is done, and moving it into a separate option that is combined with other tag types. Adding more tests. Refs #284
  Fixing use of non-existent method name.
  Adding a test case for mixing {%- and %} tags together.
  Adding a test that uses tabs. Added a test for trailing tabs and -%} Refs #284
  Implementing {%- which trims non-newline whitespace preceding it. Refs
2011-04-14 07:22:57 +02:00
Mark Story 99e3246c49 Making trim tags consume all whitespace, both horizontal and vertical. 2011-04-13 22:10:57 -04:00
Fabien Potencier d96dbb442f removed empty if 2011-04-12 16:04:26 +02:00
Fabien Potencier fbadd66852 tweaked error message when wrapping an external exception 2011-04-12 15:40:26 +02:00
Fabien Potencier 4d2727f004 made Twig_Error::findTemplateInfo() more robust 2011-04-12 14:42:00 +02:00
Fabien Potencier 34ff3b4a76 tweaked error wrapping 2011-04-12 09:32:38 +02:00
Fabien Potencier 96f2261112 removed line parameter from Twig_Template::getAttribute() and getContext() as the information is now gathered by Twig_Error_Wrapped 2011-04-12 08:12:27 +02:00
Fabien Potencier ad427be36e added a Twig_Error_Wrapped exception to try to add template name and line when a problem occurs at runtime 2011-04-12 07:59:36 +02:00
Fabien Potencier 4f37cdd08d Revert "deleted abstract method doDisplay (maintain BC)"
This reverts commit 70d90bedce.
2011-04-12 07:54:05 +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
Mark Story ec052b3ae0 Adding additional test suggested by nikic. 2011-04-05 21:36:44 -04:00
Mark Story 86bc75bfe4 Making a capturing group non capturing, as the group isn't used. 2011-04-05 21:06:58 -04:00
Mark Story 650d0f2948 Moving newline trimming into the regexp used to match end of tags. 2011-04-02 10:11:44 -04:00
Mark Story d0b40aff67 Applying changes suggested by nikic to simplify how end of comments are processed. 2011-04-02 10:08:51 -04:00
Mark Story 86b11197c0 Fixing some whitespace. 2011-04-02 10:05:55 -04:00
Mark Story d9749fcb31 Adding whitespace trimming support to other tag types (comments, variables)
Refactoring how whitespace trimming is done, and moving it into a separate option that is combined with other tag types.
Adding more tests.
Refs #284
2011-03-30 07:33:04 -04:00
Mark Story a615a3cc88 Adding a test that uses tabs.
Added a test for trailing tabs and -%}
Refs #284
2011-03-28 22:12:59 -04:00
Mark Story 22cf53fdfa Implementing {%- which trims non-newline whitespace preceding it. Refs 2011-03-28 22:12:59 -04:00
Fabien Potencier 340b22c5e0 Merge remote branch 'nikic/fixSandboxDuplicateMethodCalls'
* nikic/fixSandboxDuplicateMethodCalls:
  fix duplicate call of methods if using sandbox
2011-03-27 18:49:04 +02:00
Fabien Potencier d99edfc8f4 replaced the Twig_Environment::load() shortcut by a more useful render() one 2011-03-26 10:24:45 +01:00
Jordi Boggiano 214af8f9b5 Ensure all mbstring calls have the charset specified 2011-03-23 16:39:25 +01:00
Fabien Potencier 47fa8535b6 added Twig_Environment::load() as an alias for loadTemplate() 2011-03-22 11:58:42 +01:00
nikic 7cb09a5fbf fix duplicate call of methods if using sandbox 2011-03-17 18:27:08 +01:00
Fabien Potencier 64f8709de2 made the charset configurable for the escape filter 2011-03-17 08:02:42 +01:00
nikic 01b8c7cfae capturing {% set %} should give Twig_Markup 2011-02-18 16:12:30 +01:00