web/konrad/twig.git
11 years agorename item to attribute in the exception message because that's the term that is...
Tobias Schultze [Sun, 9 Dec 2012 16:48:08 +0000]
rename item to attribute in the exception message because that's the term that is used in twig, e.g. the  function

11 years agofurther improved exception message and distinguish array_call and any_call access
Tobias Schultze [Wed, 31 Oct 2012 20:00:51 +0000]
further improved exception message and distinguish array_call and any_call access

11 years agoadded tests for array access with confusable keys
Tobias Schultze [Wed, 31 Oct 2012 19:34:10 +0000]
added tests for array access with confusable keys

array keys like boolean, numeric but string, floats, null

11 years agofix test that that would not fail if no exception is thrown
Tobias Schultze [Sun, 9 Dec 2012 16:21:53 +0000]
fix test that that would not fail if no exception is thrown

11 years agorefactored getAttribute
Tobias Schultze [Wed, 31 Oct 2012 16:41:29 +0000]
refactored getAttribute

11 years agoimproved error message for non-existent or invalid attributes
Tobias Schultze [Wed, 31 Oct 2012 16:11:57 +0000]
improved error message for non-existent or invalid attributes

11 years agoadded changelog entry about fixed boolean array access
Tobias Schultze [Wed, 31 Oct 2012 16:51:00 +0000]
added changelog entry about fixed boolean array access

11 years agofixed getAttribute for array access with a boolean or float key
Tobias Schultze [Wed, 31 Oct 2012 16:04:56 +0000]
fixed getAttribute for array access with a boolean or float key

11 years agoupdated CHANGELOG
Fabien Potencier [Wed, 31 Oct 2012 12:42:55 +0000]
updated CHANGELOG

11 years agoadded some unit tests for previous merge
Fabien Potencier [Wed, 31 Oct 2012 12:42:47 +0000]
added some unit tests for previous merge

11 years agofix numeric keys in array
Tobias Schultze [Wed, 31 Oct 2012 11:52:26 +0000]
fix numeric keys in array

11 years agomerged branch pborreli/typos (PR #1028)
Fabien Potencier [Sun, 10 Mar 2013 07:23:01 +0000]
merged branch pborreli/typos (PR #1028)

This PR was merged into the master branch.

Commits
-------

49488b8 Fixed typos

Discussion
----------

Fixed typos

11 years agoFixed typos
Pascal Borreli [Sun, 10 Mar 2013 02:06:44 +0000]
Fixed typos

11 years agomerged branch carlwitt/patch-1 (PR #1022)
Fabien Potencier [Thu, 7 Mar 2013 06:57:14 +0000]
merged branch carlwitt/patch-1 (PR #1022)

This PR was merged into the master branch.

Commits
-------

59d0eed Update merge.rst

Discussion
----------

Update merge.rst

Typo in first line:
The merge filter merges an array with [removed: the] another array

11 years agoUpdate merge.rst
carlwitt [Mon, 4 Mar 2013 09:54:34 +0000]
Update merge.rst

Typo in first line:
The merge filter merges an array with [removed: the] another array

11 years agofixed phpdoc
Fabien Potencier [Thu, 28 Feb 2013 14:08:49 +0000]
fixed phpdoc

11 years agomerged branch Tobion/buildquery (PR #1009)
Fabien Potencier [Tue, 26 Feb 2013 13:03:39 +0000]
merged branch Tobion/buildquery (PR #1009)

This PR was squashed before being merged into the master branch (closes #1009).

Commits
-------

fcf9525 let url_encode filter also accept array of query parameters

Discussion
----------

let url_encode filter also accept array of query parameters

BC break: no
feature addition: yes
tests pass: yes
documentation: yes

This is also supported in Jinja and so it's consistent: [jinja urlencode](http://modular.math.washington.edu/home/wstein/www/home/bjarke/sage-4.4.4/local/LIB/python/site-packages/Jinja-1.2-py2.6-linux-x86_64.egg/docs/html/builtins.html)

11 years agolet url_encode filter also accept array of query parameters
Tobias Schultze [Fri, 22 Feb 2013 09:17:24 +0000]
let url_encode filter also accept array of query parameters

11 years agoMerge remote-tracking branch 'lyrixx/feat-batch-ceil'
Fabien Potencier [Tue, 26 Feb 2013 13:02:07 +0000]
Merge remote-tracking branch 'lyrixx/feat-batch-ceil'

* lyrixx/feat-batch-ceil:
  Ceil the size in batch filter

Conflicts:
test/Twig/Tests/Fixtures/filters/batch.test

11 years agomerged branch Felds/optimize-batch (PR #1007)
Fabien Potencier [Tue, 26 Feb 2013 12:59:54 +0000]
merged branch Felds/optimize-batch (PR #1007)

This PR was merged into the master branch.

Commits
-------

ccf3cd1 optimize batch function and add tests

Discussion
----------

Optimize batch function and add tests

see https://github.com/fabpot/Twig/commit/a50bc8c95be668c35cda5a6efc6a1e8413d52670#commitcomment-2665059

11 years agomerged branch minchal/master (PR #1013)
Fabien Potencier [Mon, 25 Feb 2013 06:01:12 +0000]
merged branch minchal/master (PR #1013)

This PR was merged into the master branch.

Commits
-------

c82308a deprecated use, -4 files to include.

Discussion
----------

Depraceted use of Twig_Filter_Function in Core Extension

Simple fix, that reduces included files count by 4 (in default configuration).

11 years agodeprecated use, -4 files to include.
Michał Pawłowski [Mon, 25 Feb 2013 01:03:01 +0000]
deprecated use, -4 files to include.

11 years agoremoved unneeded PHPdoc tags
Fabien Potencier [Sun, 24 Feb 2013 21:41:17 +0000]
removed unneeded PHPdoc tags

11 years agoCeil the size in batch filter
Grégoire Pineau [Fri, 22 Feb 2013 14:46:46 +0000]
Ceil the size in batch filter

11 years agooptimize batch function and add tests
Luiz “Felds” Liscia [Thu, 21 Feb 2013 15:11:54 +0000]
optimize batch function and add tests

11 years agoordered tags, filters, functions, and tests in doc indexes
Fabien Potencier [Thu, 21 Feb 2013 06:47:15 +0000]
ordered tags, filters, functions, and tests in doc indexes

11 years agoadded a batch filter
Fabien Potencier [Thu, 21 Feb 2013 06:38:58 +0000]
added a batch filter

11 years agochanged an exception to be consistent with other ones (and also to better help debugg...
Fabien Potencier [Sun, 17 Feb 2013 19:37:38 +0000]
changed an exception to be consistent with other ones (and also to better help debugging problems)

11 years agobumped version to 1.12.3-DEV
Fabien Potencier [Sat, 9 Feb 2013 18:37:02 +0000]
bumped version to 1.12.3-DEV

11 years agoprepared the 1.12.2 release
Fabien Potencier [Sat, 9 Feb 2013 18:21:53 +0000]
prepared the 1.12.2 release

11 years agoupdated CHANGELOG
Fabien Potencier [Fri, 8 Feb 2013 21:03:10 +0000]
updated CHANGELOG

11 years agoadded some unit tests for previous merge
Fabien Potencier [Fri, 8 Feb 2013 20:59:58 +0000]
added some unit tests for previous merge

11 years agoadded some missing tests
Fabien Potencier [Fri, 8 Feb 2013 19:37:43 +0000]
added some missing tests

11 years agomerged branch andrewjbaker/force-timezone (PR #964)
Fabien Potencier [Fri, 8 Feb 2013 19:01:59 +0000]
merged branch andrewjbaker/force-timezone (PR #964)

This PR was merged into the master branch.

Commits
-------

999b1c4 Force timezone setting in date filter

Discussion
----------

Force timezone setting in date filter

In instances where the $time parameter to the DateTime ctor includes a timezone, the $timezone argument is ignored. This functionality extends to the date filter.

http://uk3.php.net/manual/en/datetime.construct.php

"The $timezone parameter and the current timezone are ignored when the $time parameter either is a UNIX timestamp (e.g. @946684800) or specifies a timezone (e.g. 2010-01-28T15:00:00+02:00)."

Accepting this pull request is dependent on whether the desired functionality of the date filter should honour the PHP way of doing things, or the more logical and natural functionality anticipated by a Twig template designer; always ensuring the timezone passed into the date filter is applied.

11 years agoadded a note about how to use quotes in strings (closes #973)
Fabien Potencier [Fri, 8 Feb 2013 18:58:08 +0000]
added a note about how to use quotes in strings (closes #973)

11 years agofixed globals when getGlobals is called early on (closes #990)
Fabien Potencier [Fri, 8 Feb 2013 17:01:47 +0000]
fixed globals when getGlobals is called early on (closes #990)

11 years agomerged branch deadbeef84/getglobals-before-addglobal-bug (PR #990)
Fabien Potencier [Fri, 8 Feb 2013 16:36:01 +0000]
merged branch deadbeef84/getglobals-before-addglobal-bug (PR #990)

This PR was merged into the master branch.

Commits
-------

667b274 Added unit test for bug when calling getGlobals() before addGlobal() on Twig_Environment.

Discussion
----------

Bug when calling getGlobals() before addGlobal() on Twig_Environment.

There seems to be an issue when calling getGlobals() before addGlobal(), the globals wont get updated. It doesn't seem to matter if the global existed before the call to getGlobals(). An update of the globals can be forced by calling an additional getGlobals() after the addGlobal() call.

I believe the problem has something to do with runtimeInitialized/extensionInitialized being set to true during rendering, but globals don't get updated during that phase.

Not sure how to fix it so I'm just sending you a unit test showcasing the bug.

11 years agomerged branch lyrixx/patch-5 (PR #989)
Fabien Potencier [Fri, 8 Feb 2013 16:34:13 +0000]
merged branch lyrixx/patch-5 (PR #989)

This PR was merged into the master branch.

Commits
-------

e2a068d [Doc] Updated template_from_string to use include function

Discussion
----------

[Doc] Updated template_from_string to use include function

instead of include tag

11 years agoAdded unit test for bug when calling getGlobals() before addGlobal() on Twig_Environment.
Jesper Ek [Thu, 7 Feb 2013 23:08:43 +0000]
Added unit test for bug when calling getGlobals() before addGlobal() on Twig_Environment.

11 years ago[Doc] Updated template_from_string to use include function
Grégoire Pineau [Wed, 6 Feb 2013 10:10:34 +0000]
[Doc] Updated template_from_string to use include function

instead of include tag

11 years agomerged branch fabpot/first-last (PR #977)
Fabien Potencier [Fri, 1 Feb 2013 09:44:45 +0000]
merged branch fabpot/first-last (PR #977)

This PR was merged into the master branch.

Commits
-------

f8d4db4 added the first and last filters (closes #951)

Discussion
----------

added the first and last filters (closes #951)

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

by acasademont at 2013-01-26T20:45:23Z

:+1: great! Using twig_slice is a nice thing, we can have string and traversable objects work also with the new filters

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

by jankramer at 2013-01-30T17:39:31Z

:+1: Was actually just looking for this :) When do you think you'll merge this feature into master?

11 years agoremoved list of built-in items in the docs in favor of a link (easier to maintain...
Fabien Potencier [Thu, 31 Jan 2013 10:19:12 +0000]
removed list of built-in items in the docs in favor of a link (easier to maintain and better for discoverability)

11 years agomerged branch javiereguiluz/doc_fixes (PR #982)
Fabien Potencier [Thu, 31 Jan 2013 08:44:01 +0000]
merged branch javiereguiluz/doc_fixes (PR #982)

This PR was merged into the master branch.

Commits
-------

aac6cb6 Fixes and minor additions to the docs.

Discussion
----------

Fixes and minor additions to the docs.

11 years agoFixes and minor additions to the docs.
Javier Eguiluz [Thu, 31 Jan 2013 08:30:58 +0000]
Fixes and minor additions to the docs.

11 years agomerged branch eXtreme/patch-1 (PR #978)
Fabien Potencier [Sun, 27 Jan 2013 16:32:04 +0000]
merged branch eXtreme/patch-1 (PR #978)

This PR was merged into the master branch.

Commits
-------

8f28e78 Missing code-block in doc/templates.rst

Discussion
----------

Missing code-block in doc/templates.rst

Little tweak for docs.

11 years agoMissing code-block in doc/templates.rst
Jacek Jędrzejewski [Sun, 27 Jan 2013 10:29:20 +0000]
Missing code-block in doc/templates.rst

11 years agoadded the first and last filters (closes #951)
Fabien Potencier [Sat, 26 Jan 2013 15:59:11 +0000]
added the first and last filters (closes #951)

11 years agoadded an exception when trying to render a template when no loader has been set ...
Fabien Potencier [Sat, 26 Jan 2013 15:09:24 +0000]
added an exception when trying to render a template when no loader has been set (closes #975)

11 years agotweaked previous merge
Fabien Potencier [Sat, 26 Jan 2013 14:57:10 +0000]
tweaked previous merge

11 years agomerged branch rybakit/constant (PR #966)
Fabien Potencier [Sat, 26 Jan 2013 14:56:04 +0000]
merged branch rybakit/constant (PR #966)

This PR was merged into the master branch.

Commits
-------

a1b7ec5 Tweak twig_constant()

Discussion
----------

Tweak twig_constant()

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

by Tobion at 2013-01-16T10:52:56Z

Why is it better? The old version returns earlier.

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

by rybakit at 2013-01-16T11:25:39Z

It's better for several reasons, imho:
1. Negation has gone, which is better for perception
2. Single function exit point
3. The same functionality in less code

And what do you mean by "The old version returns earlier"?

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

by Tobion at 2013-01-16T13:33:22Z

It means the old version uses a variable less and we prefer early return statements when possible.

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

by rybakit at 2013-01-16T14:24:26Z

@Tobion, but how could it be "earlier"? In both cases the ```return``` statement goes exactly after the condition check:

1)
```php
if (!$object) {                   // 1. check condition
    return constant($constant);   // 2. return result
}
```
2)
```php
if ($object) {                    // 1. check condition
    // ...
}

return constant($constant);       // 2. return result
```
Do you want to say that case 1) is faster?

11 years agomerged branch iamdto/master (PR #969)
Fabien Potencier [Fri, 18 Jan 2013 09:58:04 +0000]
merged branch iamdto/master (PR #969)

This PR was merged into the master branch.

Commits
-------

9d25425 Fixed typo that messes up with syntax highlighting

Discussion
----------

[Documentation] Fixed typo

11 years agoFixed typo that messes up with syntax highlighting
iamdto [Fri, 18 Jan 2013 09:43:17 +0000]
Fixed typo that messes up with syntax highlighting

11 years agoremoved SVN instructions
Fabien Potencier [Wed, 16 Jan 2013 13:37:25 +0000]
removed SVN instructions

11 years agomerged branch bamarni/patch-1 (PR #967)
Fabien Potencier [Wed, 16 Jan 2013 13:36:45 +0000]
merged branch bamarni/patch-1 (PR #967)

This PR was merged into the master branch.

Commits
-------

d5de5e6 [doc] Installation - recommended Composer instead of tarball

Discussion
----------

[doc] Installation - recommended Composer instead of tarball

11 years ago[doc] Installation - recommended Composer instead of tarball
Bilal Amarni [Wed, 16 Jan 2013 13:17:17 +0000]
[doc] Installation - recommended Composer instead of tarball

11 years agoTweak twig_constant()
Eugene Leonovich [Wed, 16 Jan 2013 08:40:49 +0000]
Tweak twig_constant()

11 years agobumped version to 1.12.2-DEV
Fabien Potencier [Tue, 15 Jan 2013 20:09:05 +0000]
bumped version to 1.12.2-DEV

11 years agoprepared the 1.12.1 release
Fabien Potencier [Tue, 15 Jan 2013 20:03:45 +0000]
prepared the 1.12.1 release

11 years agotweaked previous merge
Fabien Potencier [Tue, 15 Jan 2013 19:56:11 +0000]
tweaked previous merge

11 years agomerged branch markstory/object-constants (PR #961)
Fabien Potencier [Tue, 15 Jan 2013 19:54:16 +0000]
merged branch markstory/object-constants (PR #961)

This PR was merged into the master branch.

Commits
-------

8bb953c Fix doc block for twig_constant.
c7dafb7 Update documentation for constant()
cb921ce Implement getting constants from objects.
998b367 Add tests for getting constants from instances.

Discussion
----------

Object constants

Implement the changes discussed in #954.

11 years agorelaxed globals management to avoid a BC break (closes #965)
Fabien Potencier [Tue, 15 Jan 2013 19:48:33 +0000]
relaxed globals management to avoid a BC break (closes #965)

11 years agoForce timezone setting in date filter
Andrew Baker [Mon, 14 Jan 2013 16:07:52 +0000]
Force timezone setting in date filter

11 years agoFix doc block for twig_constant.
Mark Story [Fri, 11 Jan 2013 14:42:49 +0000]
Fix doc block for twig_constant.

11 years agoUpdate documentation for constant()
Mark Story [Fri, 11 Jan 2013 04:40:58 +0000]
Update documentation for constant()

11 years agoImplement getting constants from objects.
Mark Story [Fri, 11 Jan 2013 04:38:01 +0000]
Implement getting constants from objects.

11 years agoAdd tests for getting constants from instances.
Mark Story [Fri, 11 Jan 2013 04:37:47 +0000]
Add tests for getting constants from instances.

11 years agomerged branch Taluu/patch-1 (PR #953)
Fabien Potencier [Tue, 8 Jan 2013 16:56:12 +0000]
merged branch Taluu/patch-1 (PR #953)

This PR was merged into the master branch.

Commits
-------

79c34d8 Update CHANGELOG

Discussion
----------

Update CHANGELOG

Fixes the year for the latest releases

We're not in 2012 anymore. I think.

11 years agoUpdate CHANGELOG
Baptiste Clavié [Tue, 8 Jan 2013 15:49:06 +0000]
Update CHANGELOG

Fixes the year for the latest releases

11 years agoadded support for {{ some_string[:2] }} (closes #952)
Fabien Potencier [Tue, 8 Jan 2013 14:19:16 +0000]
added support for {{ some_string[:2] }} (closes #952)

11 years agobumped version to 1.12.1-DEV
Fabien Potencier [Tue, 8 Jan 2013 14:08:36 +0000]
bumped version to 1.12.1-DEV

11 years agoprepared the 1.12.0 release
Fabien Potencier [Tue, 8 Jan 2013 13:42:43 +0000]
prepared the 1.12.0 release

11 years agotweaked CHANGELOG
Fabien Potencier [Tue, 8 Jan 2013 13:40:54 +0000]
tweaked CHANGELOG

11 years agoforbid mixed usage of raw/verbatim
Fabien Potencier [Tue, 8 Jan 2013 12:28:45 +0000]
forbid mixed usage of raw/verbatim

11 years agomerged branch fabpot/verbatim (PR #947)
Fabien Potencier [Sat, 5 Jan 2013 10:14:46 +0000]
merged branch fabpot/verbatim (PR #947)

This PR was merged into the master branch.

Commits
-------

cd4ab0f renamed the raw tag to verbatim to avoid confusion with the raw filter

Discussion
----------

renamed the raw tag to verbatim to avoid confusion with the raw filter

In Twig, we have a `raw` tag and a raw filter. Unfortunately, they are totally unrelated and that is confusing.

I propose to rename the `raw` tag to `verbatim`. Of course, for BC reasons, the old `raw` tag will be kept around for the foreseeable future as an alias to `verbatim`.

For the record, `raw` is used by Jinja (http://jinja.pocoo.org/docs/templates/#escaping), whereas `verbatim` was introduced in Django in 1.5 (https://docs.djangoproject.com/en/dev/releases/1.5/#verbatim-template-tag).

11 years agorenamed the raw tag to verbatim to avoid confusion with the raw filter
Fabien Potencier [Sat, 5 Jan 2013 07:55:59 +0000]
renamed the raw tag to verbatim to avoid confusion with the raw filter

11 years agofixed tests on PHP 5.2
Fabien Potencier [Fri, 4 Jan 2013 21:43:10 +0000]
fixed tests on PHP 5.2

11 years agofixed tests on PHP 5.2
Fabien Potencier [Fri, 4 Jan 2013 21:34:22 +0000]
fixed tests on PHP 5.2

11 years agofixed registration of tests and functions as anonymous functions (closes #946)
Fabien Potencier [Fri, 4 Jan 2013 21:19:42 +0000]
fixed registration of tests and functions as anonymous functions (closes #946)

11 years agoupdated license year
Fabien Potencier [Fri, 4 Jan 2013 16:54:54 +0000]
updated license year

11 years agoRevert "merged branch za-creature/patch-1 (PR #943)"
Fabien Potencier [Wed, 2 Jan 2013 16:15:41 +0000]
Revert "merged branch za-creature/patch-1 (PR #943)"

This reverts commit dc565f781fc885aafaceffe130121526774bc45e, reversing
changes made to 8447ca17185c082831c4d46e416f39bdeba937d9.

11 years agomerged branch za-creature/patch-1 (PR #943)
Fabien Potencier [Wed, 2 Jan 2013 15:58:50 +0000]
merged branch za-creature/patch-1 (PR #943)

This PR was merged into the master branch.

Commits
-------

15be13c Update lib/Twig/Autoloader.php

Discussion
----------

Update lib/Twig/Autoloader.php

Added the ability to register the autoloader at the top of the stack, useful in some situations.

Specifically, I need this because I want the last autoload function registered in my application to throw an exception instead of producing a class not found error, and I need *that* autoloader to be registered before twig's.

11 years agomerged branch dantleech/globals_not_array (PR #944)
Fabien Potencier [Wed, 2 Jan 2013 15:57:55 +0000]
merged branch dantleech/globals_not_array (PR #944)

This PR was squashed before being merged into the master branch (closes #944).

Commits
-------

9f5fa53 Upgrade problem

Discussion
----------

Upgrade problem

Hi

When upgrading to HEAD I got the error

Warning: array_key_exists() expects parameter 2 to be array, null given
in /home/daniel/www/DCMS/vendor/twig/twig/lib/Twig/Environment.php line
975

Caused by adding globals in the initRuntime method in my extensions.

This patch makes addGlobal handle the case where Envieonment::$globals is null.

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

by stof at 2012-12-31T14:33:17Z

Your patch does not work properly. It will allow setting the ``bar`` global when you have not called ``getGlobals`` yet now (which is why your new test is failing on Travis)

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

by dantleech at 2012-12-31T14:45:28Z

Yes, sorry, I pushed the wrong version of Environment.php. Tests should pass now.

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

by stof at 2012-12-31T14:55:29Z

I think you are now forbidding to replace an existing global without calling ``getGlobals`` first when the runtime is initialized

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

by dantleech at 2012-12-31T15:12:20Z

I think that this is the correct logic.

Throw the Exception "Unable to add global "%s" as the runtime or  the extensions have already been initialized" IF the global has not already been registered.

So, if ``$globals === null`` then this is indeed the case. The logic is the same, it just supports the default NULL value for $globals. I think.

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

by stof at 2012-12-31T15:52:50Z

no, if ``$globals === null``, it means you have not yet loaded all the globals registered previously, so you cannot know if it has already been registered this way. What you need to do is calling ``initGlobals`` in this case to be sure they are initialized

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

by dantleech at 2013-01-01T09:18:45Z

ok. updated, I think I understand -- so it is required to use ``getGlobals`` to register globals, but we cannot add globals after/during ``initRuntime``. But we could replace them:

````php
public function getGlobals()
{
   return array(
     'existing' => $this->someGlobal
   );
}
pubic function initRuntime(\Twig_Environment $e)
{
  $e->addGlobal('existing', $this->foo);  // OK
  $e->addGlobal('non-existing', $this->bar);  // FAIL
}
````

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

by darklow at 2013-01-02T15:11:46Z

This error also gives us lot of headaches, after any twig file changed first reload, got this error on array_key_exists.
Hopefully this PR could be verified and approved. Thank you.

11 years agoUpgrade problem
dantleech [Mon, 31 Dec 2012 14:04:50 +0000]
Upgrade problem

11 years agobumped version to 1.12.0-DEV
Fabien Potencier [Sun, 30 Dec 2012 20:07:31 +0000]
bumped version to 1.12.0-DEV

11 years agoprepared the 1.12.0-RC1 release
Fabien Potencier [Sun, 30 Dec 2012 19:59:54 +0000]
prepared the 1.12.0-RC1 release

11 years agoUpdate lib/Twig/Autoloader.php
za-creature [Sun, 30 Dec 2012 19:46:06 +0000]
Update lib/Twig/Autoloader.php

Added the ability to register the autoloader at the top of the stack, useful in some situations.

11 years agofixed typo in the docs
Fabien Potencier [Sun, 30 Dec 2012 16:18:01 +0000]
fixed typo in the docs

11 years agofixed wrong version in the docs
Fabien Potencier [Sun, 30 Dec 2012 15:51:54 +0000]
fixed wrong version in the docs

11 years agomerged branch fabpot/performance-fix (PR #941)
Fabien Potencier [Thu, 27 Dec 2012 16:33:50 +0000]
merged branch fabpot/performance-fix (PR #941)

This PR was merged into the master branch.

Commits
-------

2450f79 changed the way globals behave to be more BC with 1.11 and to avoid speed problems at runtime introduced in 4487387 (closes #932)

Discussion
----------

changed the way globals behave to be more BC with 1.11 and to avoid speed problems at runtime introduced in 4487387 (closes #932)

* Globals are now managed by themselves, independently of other elements
  contained in extensions

* A global variable value can now be changed after the runtime has been
  initialized (to be more BC with the way Twig 1.11 works)

* Extensions are not initialized anymore when rendering a template that
  is already in the cache (like in Twig 1.11)

11 years agoremoved PEAR related code
Fabien Potencier [Thu, 27 Dec 2012 13:40:31 +0000]
removed PEAR related code

11 years agochanged the way globals behave to be more BC with 1.11 and to avoid speed problems...
Fabien Potencier [Thu, 27 Dec 2012 08:44:14 +0000]
changed the way globals behave to be more BC with 1.11 and to avoid speed problems at runtime introduced in 4487387 (closes #932)

* Globals are now managed by themselves, independently of other elements
  contained in extensions

* A global variable value can now be changed after the runtime has been
  initialized (to be more BC with the way Twig 1.11 works)

* Extensions are not initialized anymore when rendering a template that
  is already in the cache (like in Twig 1.11)

11 years agomerged branch fabpot/render-function (PR #926)
Fabien Potencier [Tue, 25 Dec 2012 10:06:30 +0000]
merged branch fabpot/render-function (PR #926)

This PR was merged into the master branch.

Commits
-------

f4f88a5 added an include function

Discussion
----------

added an include function

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

by stof at 2012-12-09T14:12:25Z

I see an issue with this naming: it will confuse Symfony users because of the ``render`` tag doing something different than the ``render`` function. And it will force to break BC for Silex users where the subrequest logic is using a ``render`` function right now

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

by fabpot at 2012-12-10T12:49:57Z

@stof: I know about the possible confusion. For Silex, as it is not stable yet, we don't need to keep BC. And I don't have any other better name. What I want to introduce next is a `render_request` function in both Silex and Symfony (which will do the same as the current render tag in Symfony and the render function in Silex).

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

by Taluu at 2012-12-10T14:13:31Z

Hi,

I may be absent-minded, but I don't really understand the difference between `render` function and the `include` tag... ?

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

by fabpot at 2012-12-10T14:16:09Z

@Taluu Using a function allows you to do whatever you want with the output (which is not possible with a tag), like a simple:

```jinja
{{ set content = render('some_template') }}
```

Also, semantically, using a tag to output some content is less correct.

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

by vicb at 2012-12-10T14:18:17Z

could it be named `include` ?

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

by tcz at 2012-12-10T14:18:40Z

I agree that it's confusing for Symfony users. It is the same as raw filter and raw tag. I would prefer execute as name or something like that

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

by Taluu at 2012-12-10T14:19:29Z

@fabpot so, does it means that it could replace the include tag ? Then, we could could name it `include` as @vicb suggested... ?

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

by titomiguelcosta at 2012-12-10T14:21:51Z

I agree with @stof, naming it render will be confusing, parse or execute or compile are other names that come to my mind for this purpose.

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

by silentworks at 2012-12-10T14:24:36Z

How about calling it `partial`? even though you are rendering a full template, it is being included in another so this could be seeing as a partial of that template.

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

by stof at 2012-12-10T14:26:05Z

@titomiguelcosta parse is totally wrong. The function is not parsing the string you give it. you don't pass the content of the template but its name. and ``compile`` is also wrong. It is not compiling a template but rendering it.

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

by jmather at 2012-12-10T14:30:53Z

I think `render` is probably the most appropriate name, but also may cause confusion, however I don't have another suggestion that is nearly as clear as to context and meaning.

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

by emgiezet at 2012-12-10T14:31:26Z

Can you pass the array of params as an argument to the `render` function?

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

by titomiguelcosta at 2012-12-10T14:31:59Z

@stof true that we pass the filename as argument, but we end up parsing the file.

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

by stof at 2012-12-10T14:32:48Z

@emgiezet you mean passing some variables available in the included template ? Sure you can. See the doc. the argument is named ``variables``

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

by stof at 2012-12-10T14:34:36Z

@titomiguelcosta But the goal of the function is not to parse the file (btw, it may not parse it if the template was already compiled in the cache). The goal is to render the template.

Btw, I agree with @jmather. As far as Twig is concerned, ``render`` is the best name. The only issue comes from the fact that Symfony already use a ``{% render %}`` tag with a different meaning

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

by emgiezet at 2012-12-10T14:39:02Z

@stof thx a lot didn't noticed the doc link. Maybe `render_partial` will be good in this case?

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

by tcz at 2012-12-10T14:44:13Z

In an ideal world the Symfony2 `render` tag would be renamed to `subrequest` or something like that and the new function in Twig would get the `render` name. The question is how many people use Twig because of Symfony2 and how many of them use it in itself (in my company we use standalone Twig for example).

I think it's important to avoid `raw`-style confusions for the former group.

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

by stof at 2012-12-10T15:16:28Z

@tcz The issue with renaming the tag in Symfony is that it would be a BC break. So we cannot simply drop the tag (we can provide a new name and deprecate the current one, but we would still keep it).

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

by Taluu at 2012-12-10T15:18:56Z

I think `partial` would be a good idea... But still, does it mean that the `include` tag would be deprecated in favor of `render` (or whatever the name will be) function ?

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

by tcz at 2012-12-10T15:19:49Z

@stof Yes :( hence my remark "in an ideal world"

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

by stof at 2012-12-10T15:27:52Z

@Taluu It depends if @fabpot wants to keep the compatibility with Jinja where possible (as it is where the ``include`` tag comes from)

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

by WouterJ at 2012-12-10T15:48:26Z

I like the function, but I don't like the name. I like the name `partial`.

I am a front-end developer from origin and all files you include in the base CSS stylesheet are called 'partials' in SASS or other preprosessors. Twig is used to make live easier for front-end developers and I think a function called `partial` is more familiair for them than `render`.

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

by silentworks at 2012-12-10T16:17:24Z

@stof I guess based on @fabpot wanting to keep Twig compatibility with Jinja, calling the tag `partial` rather than `render` shouldn't be a problem since Jinja doesn't have any of these.

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

by Taluu at 2012-12-10T16:19:25Z

@silentworks @stof was talking about my question, about why keep the `include` tag if the `render` (or whatever the name will be) is indeed inserted into Twig. :)

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

by stof at 2012-12-10T16:19:38Z

@silentworks I was not talking about the name of the function, but about the removal of the ``include`` tag

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

by silentworks at 2012-12-10T16:22:37Z

Thanks for clarity from both.

On the basis of keeping to conformity to Jinja, should this function not be a part of twig extensions rather than in the core?

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

by mvrhov at 2012-12-10T17:20:03Z

Well search and replace for symfony users when upgrading shouldn't be that hard so I'd say that we rename the symfony block into subrequest or sth similar.

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

by Taluu at 2012-12-10T17:26:22Z

If we were to follow your recommandations, we could say the same for all and every changes inducing a BC break huh...

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

by markstory at 2012-12-10T17:49:36Z

What about naming the function `include`?  It would share a name with the tag, but it also does the same type of thing as the tag.  The function has the advantage of having its return captured.  I think  `{{ include(template) }}` semantically does what it looks like it does when operating on the template object as well.

Other names that I think could fit well are `partial` and `display`. Render works well, but I understand people not wanting to overlap with existing symfony features that do very different things.

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

by Baachi at 2012-12-10T18:13:25Z

I think "partial" is a better name for this function and it would keep BC.

11 years agomerged branch Baachi/fix-simple (PR #939)
Fabien Potencier [Tue, 18 Dec 2012 10:01:32 +0000]
merged branch Baachi/fix-simple (PR #939)

This PR was merged into the master branch.

Commits
-------

a311fe0 Fix the registration of simple filters, test and functions

Discussion
----------

Fix the registration of simple filters, test and functions

Hey!

This PR fix the registration of `Twig_SimpleFilter`, `Twig_SimpleFunction` and `Twig_SimpleTest`.
See issue #937

11 years agoFix the registration of simple filters, test and functions
Markus Bachmann [Tue, 18 Dec 2012 09:57:02 +0000]
Fix the registration of simple filters, test and functions

11 years agoadded an include function
Fabien Potencier [Thu, 15 Nov 2012 12:20:44 +0000]
added an include function

11 years agoadded emacs in the IDE support section of the docs
Fabien Potencier [Sun, 16 Dec 2012 07:55:06 +0000]
added emacs in the IDE support section of the docs

11 years agofixed small typo in the docs
Fabien Potencier [Tue, 11 Dec 2012 14:30:16 +0000]
fixed small typo in the docs

11 years agofixed regression
Fabien Potencier [Tue, 11 Dec 2012 14:22:37 +0000]
fixed regression

11 years agomerged branch fabpot/callables-everywhere (PR #905)
Fabien Potencier [Tue, 11 Dec 2012 11:12:31 +0000]
merged branch fabpot/callables-everywhere (PR #905)

This PR was merged into the master branch.

Commits
-------

1918ede added the ability to use any PHP callable to define filters, functions, and tests

Discussion
----------

added the ability to use any PHP callable to define filters, functions, and tests

Everything is in the title.

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

by Tobion at 2012-11-18T13:25:51Z

Are filters etc. slower when defined as closures (instead of function definitions)?

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

by fabpot at 2012-11-18T13:30:47Z

@Tobion No, it does not matter how they are defined. Speed will be the same. A function is probably slightly faster as we can optimize the compiled template more than when it is an anonymous function where we need to use `call_user_func`.

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

by Tobion at 2012-11-18T13:40:17Z

This slight difference is what I questioned. On top of that, PHP can also not precompile those `call_user_func` I guess (e.g. when using APC). But it's probably not a big deal.
Since you have many examples in the doc with closures, I hope that it does not become the standard way for people to define custom functions.

11 years agomerged branch fabpot/loop-errors (PR #927)
Fabien Potencier [Mon, 10 Dec 2012 20:14:37 +0000]
merged branch fabpot/loop-errors (PR #927)

This PR was merged into the master branch.

Commits
-------

811dfad added a syntax error when using a loop variable that is not defined (closes #925)
aa15cae simplified code

Discussion
----------

added a syntax error when using a loop variable that is not defined

refs #925

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

by stof at 2012-12-10T15:18:30Z

in the ifexpr, you should also check for ``loop.index`` & co as they are not yet incremented (and so cannot be used properly)

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

by fabpot at 2012-12-10T20:07:08Z

@stof fixed