Commits
-------
3eecc60 Silence chmod() warnings (operation not permitted) when using CIFS mounts and possibly other cases.
Discussion
----------
Silence chmod() warnings (operation not permitted) when using CIFS
When using chmod() in a CIFS mount (NTFS) in Linux, Twig 1.6.5 in PHP 5.3.3 throws a warning:
Warning: chmod(): Operation not permitted in /smb/.../Twig/Environment.php on line 1052
There may be other combinations that trigger this warning. Related Symfony issue: https://github.com/symfony/symfony/issues/2125
Commits
-------
c88f8e5 Micro-optimizations
70cca66 Simplify code
d78ed66 Add traversable test
5fd2f98 Add docs
b2e1675 Add is array test
Discussion
----------
is array/traversable tests
It's sometimes necessary to display arbitrary data to be able to know if we should recurse or not.
---------------------------------------------------------------------------
by stof at 2012-04-13T12:13:11Z
I'm not sure about the need for ``is array``. All Twig functions related to arrays also support traversable objects
---------------------------------------------------------------------------
by Seldaek at 2012-04-13T12:23:32Z
Well, I like to have both for explicitness and also because I would try is array without looking at the docs, and I don't think it's right to make is array return true for traversables.
---------------------------------------------------------------------------
by fabpot at 2012-04-20T09:38:33Z
One of the main goal of Twig is to abstract the "real" type of the variables. We have already discussed the introduction of many tests like these ones and I have always rejected them.
As many people seems to have a need for them (especially for arrays), I would consider adding the `traversable` test. But as @stof said, Twig tries to blur the difference between traversable objects and arrays, so I'm -1 for adding another test for arrays.
`traversable` is probably not the best name for web designers but I don't know what else we can use here.
---------------------------------------------------------------------------
by stof at 2012-04-20T09:41:05Z
In Jinja, there is a built-in test for this using ``iterable``: http://jinja.pocoo.org/docs/templates/#builtin-tests
---------------------------------------------------------------------------
by Seldaek at 2012-04-20T09:41:32Z
Ok. I can live with dropping the array test. Now for the name, `is forloopable`? I am kind of at a loss as well apart from traversable. I think if it's clearly mentioned in the docs it's ok.
---------------------------------------------------------------------------
by Seldaek at 2012-04-20T09:52:12Z
iterable sounds ok to me, but just as confusing as traversable I guess to the unknowing. A sidenote, if I update the PR, any objection to adding the "undefined" test as well?
---------------------------------------------------------------------------
by fabpot at 2012-04-20T10:01:27Z
Let's use `iterable` as this is what Jinja already uses. Why would you want an `undefined` test as we already have `defined`? (`if foo is not defined` works well enough)
---------------------------------------------------------------------------
by Seldaek at 2012-04-20T11:16:26Z
I just saw jinja had it on that page, and I thought why not add it too? Still not a huge fan of the "not" for negation.
---------------------------------------------------------------------------
by fabpot at 2012-04-20T12:18:17Z
Well, let's first finish the `iterable` test first and let's discuss `undefined` in another PR or issue.
---------------------------------------------------------------------------
by fabpot at 2012-04-20T17:10:28Z
I can finish the PR is you want.
---------------------------------------------------------------------------
by Seldaek at 2012-04-20T17:13:11Z
If you like sure, it's mostly deleting code anyway. I just have to finish some work stuff now..
Commits
-------
0cbf5a0 Added an option to mark filters as preserving the safeness
Discussion
----------
Added an option to mark filters as preserving the safeness
Closes#678
I haven't written a test for this yet as I don't know how to provide a stub filter (as none of the core filters use this option) for the setup of the testsuite.
---------------------------------------------------------------------------
by fabpot at 2012-04-07T20:15:36Z
@stof: Can you also add some information in the phpdoc with an example so that people understand more easily when and why you would want to use this new option? Thanks.
---------------------------------------------------------------------------
by fabpot at 2012-04-07T20:16:36Z
Also, adding a unit test that demonstrates the bug you had in #678 would be good.
---------------------------------------------------------------------------
by stof at 2012-04-20T08:33:58Z
@fabpot none of the core filters are using this options, so what is the right way to add a test ?
---------------------------------------------------------------------------
by fabpot at 2012-04-20T08:36:26Z
by defining a filter in the test that uses it.
---------------------------------------------------------------------------
by stof at 2012-04-20T08:39:06Z
but is it possible to register a filter from the tests with the custom stuff used by Twig ?
---------------------------------------------------------------------------
by fabpot at 2012-04-20T08:48:06Z
in integrationTest.php, we already have quite a few functions and filters registered. I would just be a matter of adding a new one.
---------------------------------------------------------------------------
by stof at 2012-04-20T16:17:01Z
@fabpot renamed, tested and squashed
Commits
-------
06361ca added note in changelog
2706412 fixed random function when charset is null
Discussion
----------
Fixed random function when charset is null
Fixed random function when charset is null and the value is an empty string, resulting in an mt_rand error max(-1) is smaller than min(0).
Also fixed a test on windows.
But I don't know why you introduced the special handling for `null === $env->getCharset()`.
Why is that necessary and why is it possible to have a null charset at all? Usually it defaults to utf-8 anyway.
Commits
-------
72d3c19 [composer] Add branch alias for dev-master, adjust some other things
Discussion
----------
[composer] Add branch alias for dev-master, adjust some other things
* branch alias allows installation of dev-master by requiring 1.7.*, which is important since most packages depend on twig "<2.0.0"
* remove the version field, the version is determined by branch names and tags only
* change license to BSD-3, this is more explicit and the preferred format for BSD licenses
* branch alias allows installation of dev-master by requiring 1.7.*, which is important since most packages depend on twig "<2.0.0"
* remove the version field, the version is determined by branch names and tags only
* change license to BSD-3, this is more explicit and the preferred format for BSD licenses
Commits
-------
2a7102d Update docs concerning loop.last.
Discussion
----------
Update docs concerning loop.last.
Add docs for #687. `loop.last` is not defined when looping with conditions.