Commit Graph

519 Commits

Author SHA1 Message Date
Fabien Potencier a27175b76a added an optimization to the Optimizer 2011-07-16 20:38:00 +02:00
nikic 5b91f12ab7 Update tests 2011-07-02 23:53:43 +02:00
Fabien Potencier 612fa7bc51 fixed json_encode filter (thanks to Koc for the fix) 2011-06-24 11:26:28 +02:00
Fabien Potencier 83a0cbab91 fixed method case-sensitivity when using the sandbox mode 2011-06-24 11:04:41 +02:00
kotas f5b9df98be added if modifier support to for loop like {% for k in v if k is odd %} 2011-06-18 04:00:46 +09:00
Fabien Potencier 027f4890a7 fixed possible security problems with NUL bytes 2011-06-17 09:17:45 +02:00
Fabien Potencier 730f9314a7 merged branch henrikbjorn/issue-347 (PR #348)
Commits
-------

a8d29b1 Add testcase for issue #347

Discussion
----------

Add testcase for issue #347

Dismisses false issue.
2011-06-16 09:45:47 +02:00
Fabien Potencier cf50380b8c merged branch nikic/nestedDefinedTestWithStrictVars (PR #359)
Commits
-------

f2a1c2b Refactor and add additional default filter tests
e760483 Make `a.b is defined` not throw an exception if a is not defined (in strict mode)

Discussion
----------

Make `a.b is defined` not throw an exception if a is not defined (in strict mode)

This commit does two things: Firstly (that's the main part) it makes `a.b is defined` not throw an error in strict mode if `a` is undefined (applies for `a.b.c` aso too) [fixes #337]. Additionally it allows `a.b|default` just like it is allowed to do `a|default`.

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

by fabpot at 2011/06/09 22:21:11 -0700

This is quite a big change. Can you add some tests?

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

by nikic at 2011/06/10 08:19:49 -0700

I added some more tests for the default filter in the fixtures. But I wasn't sure how I should test the default test's behavior in strict mode. If you could point me in the right direction here I would add those tests, too ;)
2011-06-16 09:41:50 +02:00
nikic f2a1c2b539 Refactor and add additional default filter tests 2011-06-10 16:50:20 +02:00
Arnaud Le Blanc 5ec19550b2 added {% line \d+ %} directive 2011-06-05 19:38:12 +02:00
Henrik Bjørnskov a8d29b1f84 Add testcase for issue #347 2011-06-01 15:27:40 +02:00
Tobias Naumann fc1af4b9b2 Fixes default filter 2011-05-26 11:14:22 +02:00
nikic f742efd602 Refactor GetAttr defined implementation to consider null defined 2011-05-24 12:48:47 +02:00
nikic 071210f97d Add some further is defined unit tests and give clearer names 2011-05-18 08:08:37 +02:00
nikic b0a94baebd Fix regression in defined test for GetAttr. Fixes #319 2011-05-18 08:08:32 +02:00
Fabien Potencier 48f427ebd3 added a test for the raw tag 2011-05-09 17:47:21 +02:00
Fabien Potencier 64ce3e0e62 moved a test 2011-05-09 17:47:09 +02:00
Fabien Potencier 3930ba0f4e added some tests for the use tag 2011-04-29 09:43:23 +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 e70cc161a3 added a unit test 2011-04-28 16:21:27 +02:00
Fabien Potencier a302b02cd0 Merge remote branch 'nikic/fixIncorrectGetAttrDefinedSoftCheck'
* nikic/fixIncorrectGetAttrDefinedSoftCheck:
  Use a type strict null check for GetAttr defined tests. Fixes #305
2011-04-28 16:20:15 +02:00
Fabien Potencier 2a3365a36b Revert "refactored some tests"
This reverts commit d45c980a41.

Tests should work on PHP 5.2
2011-04-28 13:18:02 +02:00
nikic 17af31b5b4 Use a type strict null check for GetAttr defined tests. Fixes #305 2011-04-28 13:17:49 +02:00
Joseph Bielawski db50167f5f Additional tests for issue #307 2011-04-27 08:01:08 -07:00
Fabien Potencier 42bcb19338 added a unit test 2011-04-15 16:21:45 +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 fbadd66852 tweaked error message when wrapping an external exception 2011-04-12 15:40:26 +02:00
Fabien Potencier d45c980a41 refactored some tests 2011-04-12 10:21:00 +02:00
Fabien Potencier d84b978e1a fixed some tests 2011-04-12 09:58:10 +02:00
Fabien Potencier 34ff3b4a76 tweaked error wrapping 2011-04-12 09:32:38 +02:00
Fabien Potencier 945b0bce9e refactored some tests 2011-04-12 09:31:35 +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 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
nikic 9a79078dd2 $e->setFilename to $e->setTemplateFile in integrationTest 2011-03-30 17:37:23 +02: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 bc4d8b32cd Fixing use of non-existent method name. 2011-03-30 07:32:06 -04:00
Mark Story 36516f67f2 Adding a test case for mixing {%- and %} tags together. 2011-03-28 22:12:59 -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 81d03de46b added some tests 2011-03-27 18:53:52 +02: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 7d78d5f7a8 added a test 2011-03-27 18:13:59 +02:00
Fabien Potencier 8ab31e0626 added some cleanup in unit tests 2011-03-27 17:50:50 +02:00
Marc Abramowitz 081b26c366 Correct spelling error (in 3 places): "unkown" -> "unknown" 2011-03-21 19:07:25 +01:00
nikic 7cb09a5fbf fix duplicate call of methods if using sandbox 2011-03-17 18:27:08 +01:00
Fabien Potencier 1ac5075879 updated documentation and added a unit test 2011-02-18 16:25:30 +01:00
nikic 01b8c7cfae capturing {% set %} should give Twig_Markup 2011-02-18 16:12:30 +01:00