Commit Graph

1746 Commits

Author SHA1 Message Date
Fabien Potencier 9f67d588c8 moved some code to the proper location 2012-12-08 09:18:33 +01:00
Fabien Potencier 3ca17acb4a added an exception when misusing macro calls (refs #922) 2012-12-07 16:14:24 +01:00
Fabien Potencier 496537a08d merged branch javiereguiluz/master (PR #923)
This PR was merged into the master branch.

Commits
-------

33539fc Fixed a typo in the 'escape' filter documentation.

Discussion
----------

Fixed a typo in the 'escape' filter documentation.

This typo prevents the proper rendering of one code block.
2012-12-06 21:30:34 +01:00
Javier Eguiluz 33539fcab3 Fixed a typo in the 'escape' filter documentation.
This typo prevents the proper rendering of one code block.
2012-12-06 19:40:31 +01:00
Fabien Potencier bc3a7e806f merged branch fabpot/twig-c-bug (PR #920)
This PR was merged into the master branch.

Commits
-------

df13370 added a missing test
33e690b fixed some tests when the extension is not enabled
51e707f merged branch char101/fix-ext-retval (PR #921)
014f459 added some missing test for Template::getAttribute()
e8d12da Fix empty string comparison
4311df3 added some missing test for Template::getAttribute()

Discussion
----------

The C extension does not behave in the same way as the PHP code

The added test shows that the C extension does not behave in the same way as the PHP code. I have no idea why. The problem is probably around line 1033 in the extension code: https://github.com/fabpot/Twig/blob/master/ext/twig/twig.c#L1033

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

by stof at 2012-12-05T17:07:00Z

The testsuite is broken when you run it without the C Twig extension. The test should be skipped when ``useExt`` is ``true`` and the extension is not available
2012-12-06 08:16:52 +01:00
Fabien Potencier df13370b22 added a missing test 2012-12-06 08:16:15 +01:00
Fabien Potencier 33e690b4db fixed some tests when the extension is not enabled 2012-12-06 08:14:48 +01:00
Fabien Potencier 51e707ffd8 merged branch char101/fix-ext-retval (PR #921)
This PR was merged into the twig-c-bug branch.

Commits
-------

e8d12da Fix empty string comparison
4311df3 added some missing test for Template::getAttribute()

Discussion
----------

Fix empty string comparison

Issue #920
2012-12-06 08:10:21 +01:00
Fabien Potencier 014f459b00 added some missing test for Template::getAttribute() 2012-12-06 08:10:02 +01:00
Charles e8d12da98c Fix empty string comparison 2012-12-06 08:39:46 +07:00
Fabien Potencier 4311df393b added some missing test for Template::getAttribute() 2012-12-05 16:40:14 +01:00
Fabien Potencier 6810dbe8a7 removed uneeded condition (a filter node cannot be created if the filer does not exist) 2012-12-01 19:41:29 +01:00
Fabien Potencier b92552f30e added missing tests for sandbox support in Template::getAttribute() 2012-12-01 19:21:32 +01:00
Fabien Potencier 35f611f22c added some missing tests for getAttribute (for isXXX methods) 2012-12-01 19:04:43 +01:00
Fabien Potencier 6d40dbdf8b merged branch fabpot/extension-registration (PR #917)
This PR was merged into the master branch.

Commits
-------

4487387 reverted the early registration of extensions (extensions are now loaded as before -- as late as possible) -- closes #910

Discussion
----------

reverted the early registration of extensions (extensions are now loaded as before -- as late as possible)

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

by stof at 2012-11-30T20:18:51Z

Looks good to me
2012-12-01 08:00:48 +01:00
Fabien Potencier 44873875ff reverted the early registration of extensions (extensions are now loaded as before -- as late as possible) -- closes #910 2012-11-30 21:04:23 +01:00
Fabien Potencier 1894f18c68 fixed typo 2012-11-30 20:22:31 +01:00
Fabien Potencier b58df0e1ae added some unit for previous merge 2012-11-26 11:25:49 +01:00
Fabien Potencier 8a65b861ac merged branch arthens/master (PR #916)
This PR was merged into the master branch.

Commits
-------

16dc94e Fix broken variable reference

Discussion
----------

Fix broken variable reference

The exception message is referencing a non-existing variable $token, renamed to $tokens.
2012-11-26 11:25:04 +01:00
Giacomo Gatelli 16dc94ef98 Fix broken variable reference 2012-11-26 04:03:31 +00:00
Fabien Potencier b4743dcfaf merged branch LouTerrailloune/patch-1 (PR #913)
This PR was merged into the master branch.

Commits
-------

c3281bb Update doc/filters/split.rst

Discussion
----------

Update doc/filters/split.rst

Added missing quotes in return values.

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

by sstok at 2012-11-23T09:17:35Z

👍
2012-11-25 13:44:18 +01:00
Fabien Potencier 0ab0d55180 merged branch catchamonkey/compiler_typo (PR #915)
This PR was merged into the master branch.

Commits
-------

ae73c4c Fixes a typo in the compiler outdent comment

Discussion
----------

Fixes a typo in the compiler outdent comment

Embarrassing really as I introduced the typo back in June.

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

by catchamonkey at 2012-11-23T13:07:58Z

Failed due to time out, I can't rerun though as I', not part of this repo.
@fabpot could you rerun or merge anyway as it's a comment change?

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

by sstok at 2012-11-25T11:56:36Z

👍
2012-11-25 13:43:34 +01:00
Chris Sedlmayr ae73c4c368 Fixes a typo in the compiler outdent comment 2012-11-23 12:22:50 +00:00
Vincent Terraillon c3281bbd03 Update doc/filters/split.rst
Added missing quotes in return values.
2012-11-22 11:21:50 +01:00
Fabien Potencier 9b75e2c7ae merged branch Tobion/refactor-core-ext (PR #907)
This PR was merged into the master branch.

Commits
-------

6deee76 refactor test_empty and in_filter

Discussion
----------

refactor test_empty and in_filter
2012-11-19 08:06:38 +01:00
Fabien Potencier 3bcf27de69 merged branch gunnarlium/master (PR #908)
This PR was merged into the master branch.

Commits
-------

a666505 Update doc for consistency.

Discussion
----------

docs: Use lipsum in all examples.

Fixes a small inconsistency in the docs for extending twig.
2012-11-19 08:06:25 +01:00
Fabien Potencier 848ed309f3 merged branch Tobion/editorconfig (PR #909)
This PR was merged into the master branch.

Commits
-------

e8ee79f added editorconfig file

Discussion
----------

added editorconfig file

This file is also in symfony. So also having it in twig would make things easier and consistent.
2012-11-19 08:06:03 +01:00
Tobias Schultze e8ee79f8ed added editorconfig file 2012-11-18 21:42:00 +01:00
Gunnar Lium a666505339 Update doc for consistency. 2012-11-18 21:17:30 +01:00
Tobias Schultze 6deee7681b refactor test_empty and in_filter 2012-11-18 21:00:04 +01:00
Fabien Potencier ca97c2feff merged branch fabpot/env-simplifications (PR #904)
This PR was merged into the master branch.

Commits
-------

0a7b37b changed the way extension filters/tests/functions/node visitors/globals/token parsers are registered (they were loaded as late as possible, they are now loaded as early as possible)

Discussion
----------

simplified some code

This PR changes the way extension filters/tests/functions/node visitors/globals/token parsers are registered (they were loaded as late as possible, they are now loaded as early as possible)

It mainly consists of a code cleanup by removing the horrible staging hack we have now.
2012-11-18 10:49:51 +01:00
Fabien Potencier 0a7b37b8cc changed the way extension filters/tests/functions/node visitors/globals/token parsers are registered (they were loaded as late as possible, they are now loaded as early as possible) 2012-11-18 10:39:05 +01:00
Fabien Potencier 51f6974cc0 tweaked documentation 2012-11-18 10:38:27 +01:00
Fabien Potencier 11368e7e08 fixed 5.2 compat 2012-11-16 21:56:44 +01:00
Fabien Potencier 7072d8f54f merged branch fabpot/tokenparserbroker (PR #903)
This PR was merged into the master branch.

Commits
-------

8563e04 deprecated the token parser broker sub-system

Discussion
----------

deprecated the token parser broker sub-system

This is the first of a series of PRs where I want to deprecate some features that made sense at some point but do not anymore or features that are barely used. Deprecated features will still work in all versions of Twig 1.x but they will be removed in Twig 2.0.

This first one should not be controversial. The token parser broker was added at a time where functions in Twig were not available. Nowadays, creating a new tag is so rare that I cannot see any usage for the broker system.

As far as I know, nobody uses the broker system anyway (this feature is not even documented), except [Zwig](https://github.com/arnaud-lb/Zwig). And Zwig should probably create functions instead of tags for ZF helpers anyways.

ping @arnaud-lb

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

by arnaud-lb at 2012-11-16T17:27:02Z

IIRC the main reason for using this in Zwig was that ZF makes it hard to list helpers, and easy to get an helper by name. So the broken allows to use ZF helpers without listing them. The reason for using tags instead of functions is that many helpers in ZF are not used for their return value and/or printing. (Zwig also exposes helpers as functions, through registerUndefinedFunctionCallback, for those used for their return value or printing.)

No objection for removing in 2.x though.
2012-11-16 18:44:55 +01:00
Fabien Potencier 8563e040c9 deprecated the token parser broker sub-system 2012-11-16 17:47:28 +01:00
Fabien Potencier 158ed4e88c merged branch fabpot/named-arguments (PR #901)
This PR was merged into the master branch.

Commits
-------

4647913 added the ability to set default values for macro arguments (closes #447)
a59dcde added support for named arguments for filters, tests, and functions
65637b7 refactored the code handling arguments for PHP callbacks when compiling nodes

Discussion
----------

Named arguments and macro default values

This PR contains two new features. Even if they are not related, the code needed to make them work was almost the same.

The first feature is the ability to use named arguments for functions, tests, and filters:

```jinja
    {{ data|convert_encoding('UTF-8', 'iso-2022-jp') }}

    {# versus #}

    {{ data|convert_encoding(from='iso-2022-jp', to='UTF-8') }}
```

The syntax is borrowed from Python where named arguments are part of the language.

The second feature is the ability to defined default values for macro arguments:

```jinja
    {% macro input(name, value = "", type = "text", size = 20) %}
        <input type="{{ type }}" name="{{ name }}" value="{{ value|e }}" size="{{ size }}" />
    {% endmacro %}

```

More information in the updated documentation.

These features have been implemented with BC in mind (which means that the code is not optimal, but it will be completely refactored for Twig 2.0 where we will get rid of all those ridiculous `Twig_Filter_*` and `Twig_Function_*` classes).

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

by fabpot at 2012-11-15T10:34:16Z

I forgot to mention that there is no overhead if you are not using these new features, and that the overhead is only at compilation time (the compiled templates are the same as before).

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

by marekkalnik at 2012-11-15T10:36:49Z

That are some great features, thanks ! 👍

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

by lolautruche at 2012-11-15T10:46:42Z

Nice ! 👍
@fabpot So I guess the old behavior is kept, isn't it ?

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

by fspillner at 2012-11-15T10:50:31Z

Awesome!

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

by fabpot at 2012-11-15T11:28:20Z

@lolautruche yes, the old way still works of course.

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

by Seldaek at 2012-11-15T11:42:40Z

Awesome! This has been much needed a few times in the past. We can almost drop php altogether and just write twig :P

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

by marfillaster at 2012-11-15T12:07:43Z

@Seldaek maybe a twig to php processor

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

by Seldaek at 2012-11-15T12:14:34Z

@marfillaster that's already what twig is :)

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

by Tobion at 2012-11-15T12:38:28Z

@fabpot nice stuff

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

by simensen at 2012-11-15T16:01:03Z

This looks great!

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

by sstok at 2012-11-15T19:18:53Z

This was basically the only thing missing I was missing in Twig
💯 👍

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

by jorgelbg at 2012-11-15T20:05:15Z

I love this new feauture, it's great to have this on Twig! Brings a lot of clarity to my future templates ;-)
2012-11-16 08:04:33 +01:00
Fabien Potencier 4647913e50 added the ability to set default values for macro arguments (closes #447) 2012-11-15 12:59:42 +01:00
Fabien Potencier a59dcde3c2 added support for named arguments for filters, tests, and functions 2012-11-15 10:23:32 +01:00
Fabien Potencier 65637b7968 refactored the code handling arguments for PHP callbacks when compiling nodes 2012-11-14 19:26:01 +01:00
Fabien Potencier e1ad2bde9c moved filters/functions/tests syntax errors to the parser 2012-11-14 14:33:08 +01:00
Fabien Potencier 2243a14e3d switched version to 1.12 2012-11-14 14:33:03 +01:00
Fabien Potencier f85076b091 added support for extended ternary operator syntaxes (closes #134) 2012-11-14 07:40:53 +01:00
Fabien Potencier b16765ce8f bumped version to 1.11.2-DEV 2012-11-11 18:22:10 +01:00
Fabien Potencier e81b98944f prepared the 1.11.1 release v1.11.1 2012-11-11 18:17:59 +01:00
Fabien Potencier 1a10ea2fbb tweaked previous merge (refs #894) 2012-11-08 10:25:11 +01:00
Fabien Potencier 818f9c7e02 merged branch char101/fix-debug-lineno (PR #894)
This PR was squashed before being merged into the master branch (closes #894).

Commits
-------

7c5854b Fix twig error lineno off by 2

Discussion
----------

Fix twig error lineno off by 2

It seems to me that the lineno reported by Twig_Error is off by 2 from the real lineno in the generated PHP source

For example:

```
{% if true %}
Yes
{% endif %}
```

```php
<?php

/*  */
class __TwigTemplate_d41d8cd98f00b204e9800998ecf8427e extends Twig_Template
{
    public function __construct(Twig_Environment $env)
    {
        parent::__construct($env);

        $this->parent = false;

        $this->blocks = array(
        );
    }

    protected function doDisplay(array $context, array $blocks = array())
    {
        // line 1
        if (true) { // <- this is line 19
            // line 2
            echo "Yes // <- this is line 21
";
        }
    }

    public function getTemplateName()
    {
        return null;
    }

    public function isTraitable()
    {
        return false;
    }

    public function getDebugInfo()
    {
        return array (  19 => 2,  17 => 1,); // <- should be return array (  21 => 2,  19 => 1,);
    }
}
```

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

by char101 at 2012-11-08T08:23:57Z

Since `$compiler->addDebugInfo()` is called first before writing the node content, usually the number of lines in the PHP code is less than 2 (1 for the // lineno comment, and 1 for the generated content) than the line where the node content is written.
2012-11-08 10:22:28 +01:00
Charles 7c5854bba9 Fix twig error lineno off by 2 2012-11-08 10:22:28 +01:00
Fabien Potencier 615804bf74 fixed regression when calling a macro inside another one (closes #889) 2012-11-08 08:57:26 +01:00
Fabien Potencier d7fed092b1 fixed typo 2012-11-08 08:51:01 +01:00