web/konrad/twig.git
13 years agoadded a Twig_Node_Expression_DefaultFilter to replace the current way of dealing...
Fabien Potencier [Sun, 16 Oct 2011 03:46:09 +0000]
added a Twig_Node_Expression_DefaultFilter to replace the current way of dealing with default filters

13 years agoadded public getters on the environment to be able to get various stuff
Fabien Potencier [Sat, 15 Oct 2011 08:57:18 +0000]
added public getters on the environment to be able to get various stuff

13 years agofixed exception
Fabien Potencier [Fri, 14 Oct 2011 23:10:30 +0000]
fixed exception

13 years agofixed download page in the docs
Fabien Potencier [Fri, 14 Oct 2011 09:46:15 +0000]
fixed download page in the docs

13 years agomerged branch trompette/patch-1 (PR #465)
Fabien Potencier [Thu, 13 Oct 2011 06:20:40 +0000]
merged branch trompette/patch-1 (PR #465)

Commits
-------

0451cfd typo

Discussion
----------

typo

13 years agotypo
Benoît Merlet [Wed, 12 Oct 2011 12:45:28 +0000]
typo

13 years agoupdated CHANGELOG
Fabien Potencier [Sat, 8 Oct 2011 12:30:37 +0000]
updated CHANGELOG

13 years agorefactored Twig_Node_Expression_GetAttr for better readability of compiled templates
Fabien Potencier [Thu, 6 Oct 2011 17:22:19 +0000]
refactored Twig_Node_Expression_GetAttr for better readability of compiled templates

13 years agooptimized variable access when possible
Fabien Potencier [Fri, 30 Sep 2011 15:04:06 +0000]
optimized variable access when possible

13 years agorefactored 'defined' test and 'default' filter
Fabien Potencier [Thu, 6 Oct 2011 14:37:14 +0000]
refactored 'defined' test and 'default' filter

Node manipulations have been moved outside the compile() method.
That's needed if we want to be able to visit all nodes that will be
compiled.

13 years agooptimized lexer by pre-computing regexes
Fabien Potencier [Thu, 6 Oct 2011 13:01:29 +0000]
optimized lexer by pre-computing regexes

13 years agomade an optimization by removing array_merge usage
Fabien Potencier [Thu, 6 Oct 2011 11:13:28 +0000]
made an optimization by removing array_merge usage

13 years agobumped version to 1.4.0-DEV
Fabien Potencier [Sat, 8 Oct 2011 12:05:18 +0000]
bumped version to 1.4.0-DEV

13 years agoprepared the 1.3.0-RC1 release
Fabien Potencier [Sat, 8 Oct 2011 12:04:10 +0000]
prepared the 1.3.0-RC1 release

13 years agoupdated CHANGELOG
Fabien Potencier [Sat, 8 Oct 2011 12:03:38 +0000]
updated CHANGELOG

13 years agoprepared the 1.3.0-RC1 release
Fabien Potencier [Tue, 4 Oct 2011 07:58:29 +0000]
prepared the 1.3.0-RC1 release

13 years agofixed a unit test for PHPUnit 3.6
Fabien Potencier [Mon, 3 Oct 2011 21:08:58 +0000]
fixed a unit test for PHPUnit 3.6

13 years agofixed optimizer
Fabien Potencier [Fri, 30 Sep 2011 20:49:47 +0000]
fixed optimizer

13 years agofixed wrong node type for the for tag
Fabien Potencier [Fri, 30 Sep 2011 14:40:46 +0000]
fixed wrong node type for the for tag

13 years agoadded an optimization for simple variables output
Fabien Potencier [Fri, 30 Sep 2011 12:54:26 +0000]
added an optimization for simple variables output

13 years agofixed hardcoded name escaping
Fabien Potencier [Fri, 30 Sep 2011 12:51:05 +0000]
fixed hardcoded name escaping

13 years agoremoved usage of PHP 5.3 __DIR__
Fabien Potencier [Thu, 29 Sep 2011 15:16:55 +0000]
removed usage of PHP 5.3 __DIR__

13 years agofixed composer version
Fabien Potencier [Thu, 29 Sep 2011 14:51:02 +0000]
fixed composer version

13 years agomerged branch igorw/composer (PR #452)
Fabien Potencier [Thu, 29 Sep 2011 14:47:57 +0000]
merged branch igorw/composer (PR #452)

Commits
-------

bd04de2 [composer] add composer.json

Discussion
----------

[composer] add composer.json

13 years agomerged branch phiamo/master (PR #454)
Fabien Potencier [Thu, 29 Sep 2011 14:46:39 +0000]
merged branch phiamo/master (PR #454)

Commits
-------

5fa0094 Added Capability to format DateInterval via twig date filter

Discussion
----------

Added Capability to format DateInterval via twig date filter

hi,
i was wondering why twig couldn't format my DateInterval and added it.

Either this is ok for you or we should add something similar for DateInterval because it uses a little bit different syntax to format its string (e.g. prepend with "%")

Cheers Phil

13 years agofixed unit test broken by previous merge
Fabien Potencier [Thu, 29 Sep 2011 14:44:28 +0000]
fixed unit test broken by previous merge

13 years agomerged branch Sannis/patch-1 (PR #455)
Fabien Potencier [Thu, 29 Sep 2011 14:39:01 +0000]
merged branch Sannis/patch-1 (PR #455)

Commits
-------

68ec644 FloorDiv (//) should return integer value according to documentation

Discussion
----------

FloorDiv (//) should return integer value according to documentation

13 years agoFloorDiv (//) should return integer value according to documentation
Oleg Efimov [Thu, 29 Sep 2011 09:24:03 +0000]
FloorDiv (//) should return integer value according to documentation

13 years agoAdded Capability to format DateInterval via twig date filter
phiamo [Thu, 29 Sep 2011 00:44:55 +0000]
Added Capability to format DateInterval via twig date filter

13 years ago[composer] add composer.json
Igor Wiedler [Tue, 27 Sep 2011 18:15:15 +0000]
[composer] add composer.json

13 years agoadded an optimization for the parent() function
Fabien Potencier [Tue, 27 Sep 2011 12:17:34 +0000]
added an optimization for the parent() function

13 years agoadded a note about the usage of Twig_Template methods
Fabien Potencier [Tue, 27 Sep 2011 12:05:30 +0000]
added a note about the usage of Twig_Template methods

13 years agorefactored documentation
Fabien Potencier [Mon, 26 Sep 2011 21:40:44 +0000]
refactored documentation

13 years agosimplified intro and added a not about the render() method in docs
Fabien Potencier [Mon, 26 Sep 2011 09:19:36 +0000]
simplified intro and added a not about the render() method in docs

13 years agofixed makup in doc
Fabien Potencier [Mon, 26 Sep 2011 08:32:52 +0000]
fixed makup in doc

13 years agomade a small optimization when a macro does not take any argument
Fabien Potencier [Sat, 24 Sep 2011 12:20:57 +0000]
made a small optimization when a macro does not take any argument

13 years agoadded cache reloading when auto_reload is true and an extension has been modified
Fabien Potencier [Sat, 24 Sep 2011 06:05:14 +0000]
added cache reloading when auto_reload is true and an extension has been modified

13 years agotweaked docs
Fabien Potencier [Fri, 23 Sep 2011 05:36:42 +0000]
tweaked docs

13 years agotweaked previous merge
Fabien Potencier [Thu, 22 Sep 2011 20:08:10 +0000]
tweaked previous merge

13 years agomerged branch runfalk/master (PR #368)
Fabien Potencier [Thu, 22 Sep 2011 20:04:27 +0000]
merged branch runfalk/master (PR #368)

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.

13 years agoadded the possibility to force the escaping of a string already marked as safe
Fabien Potencier [Thu, 22 Sep 2011 19:57:09 +0000]
added the possibility to force the escaping of a string already marked as safe

13 years agoadded traits support for the parent function
Fabien Potencier [Thu, 22 Sep 2011 10:03:40 +0000]
added traits support for the parent function

13 years agoallowed empty templates to be used as traits
Fabien Potencier [Thu, 22 Sep 2011 09:51:27 +0000]
allowed empty templates to be used as traits

13 years agobumped version to 1.3.0-DEV
Fabien Potencier [Thu, 22 Sep 2011 09:30:08 +0000]
bumped version to 1.3.0-DEV

13 years agoprepared 1.2.0 release
Fabien Potencier [Tue, 13 Sep 2011 15:01:30 +0000]
prepared 1.2.0 release

13 years agoprepared 1.2.0-RC1 release
Fabien Potencier [Sat, 10 Sep 2011 06:57:30 +0000]
prepared 1.2.0-RC1 release

13 years agoadded an exception for unclosed tags
Fabien Potencier [Tue, 6 Sep 2011 11:42:02 +0000]
added an exception for unclosed tags

13 years agoupdated CHANGELOG
Fabien Potencier [Tue, 6 Sep 2011 07:15:46 +0000]
updated CHANGELOG

13 years agomerged branch maxromanovsky/master (PR #431)
Fabien Potencier [Tue, 6 Sep 2011 07:14:27 +0000]
merged branch maxromanovsky/master (PR #431)

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)

13 years agoAdded: Countable interface support for empty test
Max Romanovsky [Sun, 4 Sep 2011 12:13:42 +0000]
Added: Countable interface support for empty test

13 years agoadded more unit tests
Fabien Potencier [Thu, 1 Sep 2011 08:50:13 +0000]
added more unit tests

13 years agoremoved some loop variable when using an if statement in a for loop
Fabien Potencier [Thu, 1 Sep 2011 08:40:40 +0000]
removed some loop variable when using an if statement in a for loop

13 years agomade a markup refactoring
Fabien Potencier [Thu, 1 Sep 2011 07:16:08 +0000]
made a markup refactoring

13 years agofixed algorithm that determines if a template using inheritance is valid (no output...
Fabien Potencier [Thu, 1 Sep 2011 06:08:16 +0000]
fixed algorithm that determines if a template using inheritance is valid (no output between block definitions)

13 years agotweaked an error message
Fabien Potencier [Thu, 1 Sep 2011 06:06:05 +0000]
tweaked an error message

13 years agorenamed a class in unit test to avoid confusion with PHPStorm
Fabien Potencier [Wed, 31 Aug 2011 09:10:12 +0000]
renamed a class in unit test to avoid confusion with PHPStorm

13 years agofixed resolveTemplate() method (we only catch loader exceptions)
Fabien Potencier [Tue, 30 Aug 2011 20:58:17 +0000]
fixed resolveTemplate() method (we only catch loader exceptions)

13 years agoadded better support for encoding problems when escaping a string (available as of...
Fabien Potencier [Tue, 30 Aug 2011 05:35:55 +0000]
added better support for encoding problems when escaping a string (available as of PHP 5.4)

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.

13 years agosimplified previous merge
Fabien Potencier [Mon, 29 Aug 2011 16:47:24 +0000]
simplified previous merge

13 years agofixed CS
Fabien Potencier [Mon, 29 Aug 2011 16:26:53 +0000]
fixed CS

13 years agomerged branch Brouznouf/patch-1 (PR #425)
Fabien Potencier [Mon, 29 Aug 2011 16:26:20 +0000]
merged branch Brouznouf/patch-1 (PR #425)

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

13 years agoRemoving array_shift for optimisation.
Joel Wurtz [Tue, 30 Aug 2011 03:02:31 +0000]
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

13 years agofixed markup in the doc
Fabien Potencier [Sun, 28 Aug 2011 07:12:46 +0000]
fixed markup in the doc

13 years agoadded support for an array of templates to the "extends" tag
Fabien Potencier [Sat, 27 Aug 2011 12:33:01 +0000]
added support for an array of templates to the "extends" tag

13 years agoadded a way to ignore a missing template when using the "include" tag
Fabien Potencier [Sat, 27 Aug 2011 11:54:33 +0000]
added a way to ignore a missing template when using the "include" tag

13 years agoadded support for an array of templates to the include tag
Fabien Potencier [Sat, 27 Aug 2011 11:37:56 +0000]
added support for an array of templates to the include tag

13 years agoupdated CHANGELOG
Fabien Potencier [Sat, 27 Aug 2011 09:11:38 +0000]
updated CHANGELOG

13 years agomerged branch jturmel/master (PR #403)
Fabien Potencier [Sat, 27 Aug 2011 09:10:29 +0000]
merged branch jturmel/master (PR #403)

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 %}``

13 years agoreplace file_exists() by is_file() as this is semantically more correct (we don't...
Fabien Potencier [Sat, 27 Aug 2011 07:56:45 +0000]
replace file_exists() by is_file() as this is semantically more correct (we don't want dirs to match)

13 years agoreplaced usage of array_replace by array_merge (for 5.2 compatibility)
Fabien Potencier [Sat, 27 Aug 2011 07:38:43 +0000]
replaced usage of array_replace by array_merge (for 5.2 compatibility)

13 years agoadded the "attribute" function to allow getting dynamic attributes on variables
Fabien Potencier [Sat, 27 Aug 2011 07:26:51 +0000]
added the "attribute" function to allow getting dynamic attributes on variables

13 years agoadded Twig_Loader_Chain
Fabien Potencier [Wed, 24 Aug 2011 10:56:57 +0000]
added Twig_Loader_Chain

13 years agorenamed a test file
Fabien Potencier [Wed, 24 Aug 2011 10:54:04 +0000]
renamed a test file

13 years agoadded Twig_LoaderArray::setTemplate()
Fabien Potencier [Wed, 24 Aug 2011 10:16:12 +0000]
added Twig_LoaderArray::setTemplate()

13 years agoswitcher PHPUnit colors to true
Fabien Potencier [Wed, 24 Aug 2011 10:15:02 +0000]
switcher PHPUnit colors to true

13 years agomerged branch videlalvaro/patch-1 (PR #419)
Fabien Potencier [Thu, 18 Aug 2011 17:16:29 +0000]
merged branch videlalvaro/patch-1 (PR #419)

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

13 years agoEdited doc/templates.rst via GitHub
Alvaro Videla [Tue, 16 Aug 2011 13:27:40 +0000]
Edited doc/templates.rst via GitHub

13 years agochanged unit tests so that they work for PHP 5.2
Fabien Potencier [Mon, 8 Aug 2011 21:00:24 +0000]
changed unit tests so that they work for PHP 5.2

13 years agomoved some logic to the constructor (that's allows visitors to have the real node...
Fabien Potencier [Sun, 7 Aug 2011 19:32:22 +0000]
moved some logic to the constructor (that's allows visitors to have the real node that will be compiled)

13 years agoadded an optimization for the set tag when used to capture a large chunk of static...
Fabien Potencier [Tue, 26 Jul 2011 21:22:49 +0000]
added an optimization for the set tag when used to capture a large chunk of static text

13 years agoremoved unneeded implementation of Template::getTemplateName()
Fabien Potencier [Sun, 7 Aug 2011 15:26:48 +0000]
removed unneeded implementation of Template::getTemplateName()

13 years agochanged name regex to allow more characters (the same as PHP - works for blocks,...
Fabien Potencier [Sun, 7 Aug 2011 08:07:35 +0000]
changed name regex to allow more characters (the same as PHP - works for blocks, tags, functions, filters, and macros - closes #376)

13 years agomerged branch nikic/doNotUseNameNodeForFuncNames (PR #410)
Fabien Potencier [Sun, 7 Aug 2011 07:37:28 +0000]
merged branch nikic/doNotUseNameNodeForFuncNames (PR #410)

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.

13 years agoDo not use Node_Expression_Name for function names, just use strings for those
nikic [Sun, 3 Jul 2011 10:26:50 +0000]
Do not use Node_Expression_Name for function names, just use strings for those

13 years agoremoved obsolete code
Fabien Potencier [Sat, 6 Aug 2011 08:56:03 +0000]
removed obsolete code

13 years agorefactored code
Fabien Potencier [Sat, 6 Aug 2011 08:44:55 +0000]
refactored code

13 years agoadded the possibility to test for exceptions in integration tests
Fabien Potencier [Sat, 6 Aug 2011 07:48:38 +0000]
added the possibility to test for exceptions in integration tests

13 years agoremoved the possibility to use the extends tag from a block (as it is semantically...
Fabien Potencier [Sat, 6 Aug 2011 07:16:03 +0000]
removed the possibility to use the extends tag from a block (as it is semantically incorrect and it probably does not work as you expect it to in this case)

13 years agomoved Template::getParent() logic to the base class
Fabien Potencier [Sat, 6 Aug 2011 07:09:18 +0000]
moved Template::getParent() logic to the base class

13 years agoadded documentation for previous merge
Fabien Potencier [Sat, 6 Aug 2011 06:40:52 +0000]
added documentation for previous merge

13 years agofixed unit tests for previous merge
Fabien Potencier [Sat, 6 Aug 2011 06:35:41 +0000]
fixed unit tests for previous merge

13 years agomerged branch kotas/master (PR #362)
Fabien Potencier [Sat, 6 Aug 2011 06:34:15 +0000]
merged branch kotas/master (PR #362)

Commits
-------

f5b9df9 added `if` modifier support to for loop like {% for k in v if k is odd %}

Discussion
----------

[1.2] added `if` modifier support to for loop

Hi.

I'm one of Twig users who love it so much. :)

I've made a patch for adding `if` modifier support to `for` loop in Twig.

Example:
<pre>
{% for n in range(0, 5) if n is odd %}
  {{ n }}
{% endfor %}
</pre>

Output:
<pre>
1
3
5
</pre>

This idea comes from Python's list comprehensions. (like `[n for n in range(0,6) if n % 2 == 1]`)

Here is another example.

Before:
<pre>
{% set no_items = true %}
{% for item in items %}
  {% if item.available %}
    {% set no_items = false %}
    {{ item.name }}
  {% endif %}
{% endfor %}
{% if no_items %}
  No items available.
{% endif %}
</pre>

After:
<pre>
{% for item in items if item.available %}
  {{ item.name }}
{% else %}
  No items available.
{% endfor %}
</pre>

I hope you like it. But If not, just ignore this request. :)

Thanks.

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

by fabpot at 2011/06/24 01:33:33 -0700

I like it! I will schedule it for inclusion in Twig 1.2. Thanks.

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

by hhamon at 2011/06/26 16:43:26 -0700

+1

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

by nikic at 2011/06/27 00:42:14 -0700

I think the idea per se is interesting. But I just checked all Twig templates in my whole codebase and couldn't find any use for it. What was your practical use for this feature @kotas?

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

by kotas at 2011/06/27 01:52:48 -0700

@nikic My practical use is shown as the second example in the body of this pull request.

Sometimes you need to "filter" an array by seeing its element's property like "item.available" or by some condition like "item.price >= 500".

To do this, in the current version of Twig, you have to write "for" and "if" as nested scopes. And if you want to write {% else %} of the "for" loop, you have to make a temporary variable to see if all elements are skipped.

I think this feature is not essential, but makes templates clean.

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

by nikic at 2011/06/27 06:23:24 -0700

The thing about `else` seems plausible. +1

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

by chucktrukk at 2011/08/02 17:39:16 -0700

Also +1. that makes some very clean template code.

13 years agoadded GtkSourceView support in doc
Fabien Potencier [Sat, 6 Aug 2011 06:16:57 +0000]
added GtkSourceView support in doc

13 years agomerged branch igorw/recipes-highlight (PR #405)
Fabien Potencier [Thu, 4 Aug 2011 08:29:19 +0000]
merged branch igorw/recipes-highlight (PR #405)

Commits
-------

0580f19 fix highlighting of snippet in recipes doc

Discussion
----------

fix highlighting of snippet in recipes doc

13 years agofix highlighting of snippet in recipes doc
Igor Wiedler [Sun, 31 Jul 2011 00:25:43 +0000]
fix highlighting of snippet in recipes doc

13 years agobumped version to 1.2.0-DEV
Fabien Potencier [Sat, 30 Jul 2011 08:10:16 +0000]
bumped version to 1.2.0-DEV

13 years agoprepared 1.1.2 released
Fabien Potencier [Sat, 30 Jul 2011 07:52:15 +0000]
prepared 1.1.2 released

13 years agofixed Parser bug when a child node is null
Fabien Potencier [Thu, 28 Jul 2011 12:32:45 +0000]
fixed Parser bug when a child node is null

13 years agofixed Parser bug
Fabien Potencier [Thu, 28 Jul 2011 12:32:07 +0000]
fixed Parser bug

13 years agoAdd bitwise operators to core
Josh Turmel [Wed, 27 Jul 2011 07:10:01 +0000]
Add bitwise operators to core

* Added bitwise operators (and, xor, or) to core