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
👍
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
👍
This PR was merged into the master branch.
Commits
-------
6deee76 refactor test_empty and in_filter
Discussion
----------
refactor test_empty and in_filter
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.
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.
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.
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.
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 ;-)
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.
This PR was merged into the master branch.
Commits
-------
55b76c1 Fix extension crash when calling unknown method inside a macro
Discussion
----------
Fix extension crash when calling unknown method inside a macro
Issue #890
This PR was squashed before being merged into the master branch (closes#893).
Commits
-------
f397a8f Use ternary operator with PHP 5.4 when strict_variables is true
Discussion
----------
Use ternary operator with PHP 5.4 when strict_variables is true
When strict variables is true, and using PHP 5.4, we can still use the ternary operator to optimize performance.
This PR was merged into the master branch.
Commits
-------
cc65c88 [template_from_string]Fixed typo
Discussion
----------
[template_from_string]Fixed typo in docs
Fix a typo in the template_from_string function docs
This PR was merged into the master branch.
Commits
-------
3164ee3 Fix build warning for const pointer
Discussion
----------
Fix build warning for const pointer
Issue #883
This PR was merged into the master branch.
Commits
-------
db13b66 Pass lineno and filename to Twig_Error constructor
feee667 Merge branch 'nativeext-exception-info' of https://github.com/fabpot/Twig into nativeext-exception-info
adb31d4 Call Twig_Error constructor
d4a8c8b added tests for exceptions thrown in Twig_Template::getAttribute()
1b82bf7 Add template filename for the rest of the exception
5675140 Handle NULL filename
71f64bc Add template name to error message
Discussion
----------
Add template name to error message
Issue #884
---------------------------------------------------------------------------
by fabpot at 2012-11-06T07:43:16Z
For some unknown reasons, I don't see your branch when I try to submit a PR. Can you cherry-pick my unit tests from my `nativeext-exception-info` branch?
---------------------------------------------------------------------------
by Tobion at 2012-11-06T08:29:19Z
@char101 Maybe you could also integrate the fixes of #878?
---------------------------------------------------------------------------
by fabpot at 2012-11-06T08:30:55Z
@Tobion Let's do one thing at a time.
---------------------------------------------------------------------------
by char101 at 2012-11-06T08:59:30Z
@Tobion AFAIK, unlike the PHP implementation, the C implementation does not automatically convert array key type.
---------------------------------------------------------------------------
by char101 at 2012-11-06T09:27:54Z
@fabpot How about the lineno variable? Should I just set it to 0 or is there any function that can be called to obtain it?
```php
if (-1 === $this->lineno || null === $this->filename) {
$this->guessTemplateInfo();
}
```
---------------------------------------------------------------------------
by fabpot at 2012-11-06T09:32:09Z
You need to keep `-1` for the line.
---------------------------------------------------------------------------
by char101 at 2012-11-06T09:36:56Z
If `$lineno` is `-1`, wouldn't `$this->guessTemplateInfo()` still be called?
---------------------------------------------------------------------------
by fabpot at 2012-11-06T09:45:34Z
Yes, but the template name will not be guessed. So, there is a performance overhead for the line guessing, but not for the template name guessing.