Commits
-------
eb5c9fb Recipe code formatting fix. New recipe for improved APC bytecode support
Discussion
----------
APC recipe
A new recipe to support cache invalidation when using *APC* with *apc.stat* = 0 and compiled code caching turned on. One sometimes want to test things without restarting apache. This recipe overrides *writeCacheFile* in *Twig_Environment* and calls *apc_compile_file to refresh cache.
Commits
-------
4b95621 Added: Countable interface support for empty test
Discussion
----------
Countable interface support for empty test
See [issue](https://github.com/fabpot/Twig/issues/430)
From the PHP CHANGELOG:
The flag ENT_SUBSTITUTE makes invalid multibyte sequences be replaced by
U+FFFD (UTF-8) or &#FFFD; by htmlspecialchars and htmlentities. It is an
alternative to the default behavior, which just returns an empty string and to
ENT_IGNORE, which is a security risk. The behavior follows the recommendations
of Unicode Technical Report #36.
Commits
-------
4dc490f Removing array_shift for optimisation.
Discussion
----------
Removing array_shift for optimisation.
For example we check if a template and use exception to redirect to a default template
Before : We checked ~1000 times => 100sec due to array_shift
After : ~1sec
For example we check if a template and use exception to redirect to a default template
Before : We checked ~1000 times => 100sec due to array_shift
After : ~1sec
Commits
-------
c2c01de Add bitwise operators to core
Discussion
----------
Added bitwise operators (and, xor, or) to core
* Added bitwise operators (and, xor, or) to core
---------------------------------------------------------------------------
by nikic at 2011/08/02 21:02:14 -0700
I'm not sure bitwise ops really belong into a templateing language...
---------------------------------------------------------------------------
by jturmel at 2011/08/02 21:06:02 -0700
That's a general statement to make without knowing why it was implemented at all... no one is forced to use them, however when you do need them, them not being available makes you have relegate something that should be in the view in the particular case I needed them, to be done in a controller instead, which would be quite a bit nastier in my case.
---------------------------------------------------------------------------
by nikic at 2011/08/02 23:23:30 -0700
@jturmel: I do not doubt that there are some cases where bitwise operations are useful. I can't think of one of the top of my head, though I imagine that it could be useful when using bitwise right management or something like that. What I was trying to say is, that I don't really believe that there are enough significant use cases for bitwise ops to justify adding them to the core (I know, "You Don't Have To Use It!", but it isn't good to clutter the core with features nearly no one uses). Maybe you could give an example of what you needed them for?
---------------------------------------------------------------------------
by jturmel at 2011/08/02 23:41:36 -0700
It would be one thing if I was implementing some operator that didn't normally exist in PHP itself, but it seems a bit odd to even say that it's cluttering it up, it's 3 lines of code that add 3 missing standard operators from PHP.
Simply put, I have an object that gets passed to the template that has many properties, these properties are bit values, I need to do checks on them to select/deselect various checkboxes in a grid... this is the cleanest way to do it without mudding up controller code with view logic.
---------------------------------------------------------------------------
by jalliot at 2011/08/03 01:42:56 -0700
Why not adding ``<<`` and ``>>`` then @jturmel?
I don't have a particular use case but I think that if Twig includes those 3 operators, it should also support these 2 to be "complete". What do you think?
---------------------------------------------------------------------------
by jturmel at 2011/08/03 06:07:46 -0700
Of course, if you guys think we need the shifting operators as well, we can... but modifying data in the view seems much less practical than the one's I added, although I did miss NOT.
---------------------------------------------------------------------------
by jalliot at 2011/08/03 06:16:38 -0700
I forgot about ``~`` but sure it should be included as well.
As for ``<<`` and ``>>``, they could also be used for verifying grant access for example in some implementations.
``{% if some_var << some_other_var & 1 %}``
Commits
-------
0ef1cb0 Edited doc/templates.rst via GitHub
Discussion
----------
Edited doc/templates.rst via GitHub
I fixed a typo: Variables can by for Variables can be
Commits
-------
da4d964 Do not use Node_Expression_Name for function names, just use strings for those
Discussion
----------
Do not use Node_Expression_Name for function names
This patch remove the use of Node_Expression_Name for function names and instead uses normal strings for those. This is mainly to prevent problems with static analysis (e.g. using a loop() function would have triggered with_loop), but it also slightly reduces complexity.