web/konrad/twig.git
12 years agosimplified code
Fabien Potencier [Mon, 2 Jan 2012 13:20:16 +0000]
simplified code

12 years agoadded a unit test
Fabien Potencier [Mon, 2 Jan 2012 12:14:06 +0000]
added a unit test

12 years agoadded Traversable objects support for the join filter
Fabien Potencier [Mon, 2 Jan 2012 12:10:08 +0000]
added Traversable objects support for the join filter

12 years agoprepared the 1.5.0-RC2 release
Fabien Potencier [Fri, 30 Dec 2011 15:23:51 +0000]
prepared the 1.5.0-RC2 release

12 years agoupdated doc for the date filter
Fabien Potencier [Fri, 30 Dec 2011 08:21:01 +0000]
updated doc for the date filter

12 years agoadded a way to set the default global date interval format
Fabien Potencier [Fri, 30 Dec 2011 08:15:53 +0000]
added a way to set the default global date interval format

12 years agorefactored date filter code
Fabien Potencier [Fri, 30 Dec 2011 07:58:12 +0000]
refactored date filter code

12 years agomerged branch alefranz/patch-2 (PR #575)
Fabien Potencier [Fri, 30 Dec 2011 07:50:36 +0000]
merged branch alefranz/patch-2 (PR #575)

Commits
-------

b295274 fix Date Format filter: DateInterval does not provide setTimezone()

Discussion
----------

fix Date Format filter: DateInterval does not provide setTimezone()

12 years agofix Date Format filter: DateInterval does not provide setTimezone()
alefranz [Thu, 29 Dec 2011 18:46:53 +0000]
fix Date Format filter: DateInterval does not provide setTimezone()

12 years agorefactored Twig_Template::display() to ease its extension
Fabien Potencier [Wed, 28 Dec 2011 22:05:59 +0000]
refactored Twig_Template::display() to ease its extension

12 years agotweaked previous merge
Fabien Potencier [Wed, 28 Dec 2011 19:34:32 +0000]
tweaked previous merge

12 years agomerged branch markstory/number-format (PR #573)
Fabien Potencier [Wed, 28 Dec 2011 19:32:43 +0000]
merged branch markstory/number-format (PR #573)

Commits
-------

e3b81ad Add documentation page for number_format.
0edcfdd Add number_format filter.

Discussion
----------

Implement number_format filter

Implement a `number_format` filter that wraps the native PHP `number_format`.

Fixes #417

12 years agoAdd documentation page for number_format.
Mark Story [Wed, 28 Dec 2011 16:13:27 +0000]
Add documentation page for number_format.

12 years agoAdd number_format filter.
Mark Story [Wed, 28 Dec 2011 15:39:04 +0000]
Add number_format filter.

Refs #417

12 years agofixed Twig_Node_Expression_Array::hasElement()
Fabien Potencier [Mon, 26 Dec 2011 21:06:43 +0000]
fixed Twig_Node_Expression_Array::hasElement()

12 years agoprepared the 1.5.0-RC1 release
Fabien Potencier [Mon, 26 Dec 2011 10:40:36 +0000]
prepared the 1.5.0-RC1 release

12 years agofixed markup
Fabien Potencier [Mon, 26 Dec 2011 10:32:17 +0000]
fixed markup

12 years agoadded missing doc for the do tag
Fabien Potencier [Mon, 26 Dec 2011 10:21:22 +0000]
added missing doc for the do tag

12 years agofixed typo
Fabien Potencier [Mon, 26 Dec 2011 10:17:02 +0000]
fixed typo

12 years agochanged hash key expression support (expression must now be enclosed with parentheses...
Fabien Potencier [Mon, 26 Dec 2011 08:35:38 +0000]
changed hash key expression support (expression must now be enclosed with parentheses and hash keys can now be names)

12 years agomerged branch jeserkin/jeserkin (PR #570)
Fabien Potencier [Mon, 26 Dec 2011 08:08:00 +0000]
merged branch jeserkin/jeserkin (PR #570)

Commits
-------

fd78ec0 Fixed PhpDoc for Twig_TokenParserInterface and all other TokenParsers

Discussion
----------

Fixed PhpDoc for Twig_TokenParserInterface and all other TokenParsers

12 years agoFixed PhpDoc for Twig_TokenParserInterface and all other TokenParsers
Eugene Serkin [Sun, 25 Dec 2011 23:55:03 +0000]
Fixed PhpDoc for Twig_TokenParserInterface and all other TokenParsers

12 years agoadded convenience methods to manipulate an array node
Fabien Potencier [Sun, 25 Dec 2011 21:34:12 +0000]
added convenience methods to manipulate an array node

12 years agoRevert "Revert "merged branch arnaud-lb/hash-key-expr (PR #514)""
Fabien Potencier [Sat, 24 Dec 2011 08:22:35 +0000]
Revert "Revert "merged branch arnaud-lb/hash-key-expr (PR #514)""

This reverts commit 99b2c5bf99ea299685886e33d54fbbcd6348b849.

12 years agomerged branch javiereguiluz/add-nl2br-notice (PR #568)
Fabien Potencier [Fri, 23 Dec 2011 10:29:22 +0000]
merged branch javiereguiluz/add-nl2br-notice (PR #568)

Commits
-------

7194b1a Added a notice in the `nl2br` filter documentation about the proper Twig version to use it

Discussion
----------

Added a notice in the `nl2br` filter documentation ...

... about the proper Twig version to use it (1.5)

12 years agoAdded a notice in the `nl2br` filter documentation about the proper Twig version...
Javier Eguíluz [Fri, 23 Dec 2011 09:26:49 +0000]
Added a notice in the `nl2br` filter documentation about the proper Twig version to use it

12 years agoRevert "merged branch arnaud-lb/hash-key-expr (PR #514)"
Fabien Potencier [Fri, 23 Dec 2011 07:58:23 +0000]
Revert "merged branch arnaud-lb/hash-key-expr (PR #514)"

This reverts commit 8665c6463461ccd0afec1ff943b45b56ad01a06e, reversing
changes made to 4aba337cda03b0170cbf30b43cd82cb83146f2b4.

12 years agoupdated doc
Fabien Potencier [Thu, 22 Dec 2011 21:48:48 +0000]
updated doc

12 years agoupdated CHANGELOG
Fabien Potencier [Thu, 22 Dec 2011 21:42:44 +0000]
updated CHANGELOG

12 years agomerged branch arnaud-lb/hash-key-expr (PR #514)
Fabien Potencier [Thu, 22 Dec 2011 21:41:37 +0000]
merged branch arnaud-lb/hash-key-expr (PR #514)

Commits
-------

542e9e7 added getKeyValuePairs() on Twig_Node_Expression_Array
3f64f1d added test for hash keys
4bdb3a9 fixed tests
3b1f269 support any expression as hash key

Discussion
----------

Allow hash keys to be any expression

This allows hash keys to be any expression

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

by fabpot at 2011/12/07 02:08:19 -0800

I had not implemented this feature back then because I'm not sure it makes sense to support it in the context of a templating system. I'm still not convinced that this is useful.

12 years agoadded a do tag (closes #446)
Fabien Potencier [Thu, 22 Dec 2011 21:32:27 +0000]
added a do tag (closes #446)

12 years agoadded doc for the flush tag
Fabien Potencier [Thu, 22 Dec 2011 18:32:51 +0000]
added doc for the flush tag

12 years agoadded IDE support for Coda in the doc (closes #566)
Fabien Potencier [Thu, 22 Dec 2011 18:25:03 +0000]
added IDE support for Coda in the doc (closes #566)

12 years agotweaked doc (closes #567)
Fabien Potencier [Thu, 22 Dec 2011 13:20:20 +0000]
tweaked doc (closes #567)

12 years agoreplaced zend_error_noreturn calls to zend_error as zend_error_noreturn is not export...
Fabien Potencier [Thu, 22 Dec 2011 13:17:52 +0000]
replaced zend_error_noreturn calls to zend_error as zend_error_noreturn is not exported (closes #554)

12 years agomerged branch arnaud-lb/ext-fix (PR #565)
Fabien Potencier [Wed, 21 Dec 2011 19:27:52 +0000]
merged branch arnaud-lb/ext-fix (PR #565)

Commits
-------

b26d69a removed bogus TSRMLS_CCs

Discussion
----------

Fix strict mode in extension when building in ZTS mode

This removes a few misplaced TSRMLS_CCs causing if() expressions to always evaluate to true. This caused twig_template_get_attributes to always behave as if strict mode were disabled.

12 years agofixed typo
Fabien Potencier [Wed, 21 Dec 2011 19:17:43 +0000]
fixed typo

12 years agoremoved bogus TSRMLS_CCs
Arnaud Le Blanc [Wed, 21 Dec 2011 18:48:50 +0000]
removed bogus TSRMLS_CCs

12 years agoadded a flush tag
Fabien Potencier [Wed, 21 Dec 2011 18:34:14 +0000]
added a flush tag

12 years agomerged branch nikic/fixLoopIncrement (PR #563)
Fabien Potencier [Wed, 21 Dec 2011 10:25:50 +0000]
merged branch nikic/fixLoopIncrement (PR #563)

Commits
-------

8255b8b Fix test for previous commit
834ce4c Fix loop increment on some for loops (fix #562)

Discussion
----------

Fix loop increment

PR for #562.

12 years agoFix test for previous commit
nikic [Wed, 21 Dec 2011 10:05:19 +0000]
Fix test for previous commit

12 years agoFix loop increment on some for loops (fix #562)
nikic [Wed, 21 Dec 2011 10:00:04 +0000]
Fix loop increment on some for loops (fix #562)

The inner loop incrementing code was not added on for loops where the body was not a Twig_Node (but e.g. a Twig_Node_If)

12 years agofixed dump when xdebug.overload_var_dump is not defined in php.ini
Fabien Potencier [Sun, 18 Dec 2011 19:54:12 +0000]
fixed dump when xdebug.overload_var_dump is not defined in php.ini

12 years agoadded support for dynamically named filters and functions
Fabien Potencier [Sun, 20 Nov 2011 08:00:09 +0000]
added support for dynamically named filters and functions

12 years agomade the dump function registration explicit and disable its output when debug is off
Fabien Potencier [Sun, 18 Dec 2011 19:20:13 +0000]
made the dump function registration explicit and disable its output when debug is off

12 years agofixed dump function when the context contains Twig_Template instances
Fabien Potencier [Sun, 18 Dec 2011 19:11:39 +0000]
fixed dump function when the context contains Twig_Template instances

12 years agoadded a dump function to help debugging templates
Fabien Potencier [Sun, 18 Dec 2011 17:08:58 +0000]
added a dump function to help debugging templates

12 years agofixed the random function
Fabien Potencier [Sun, 18 Dec 2011 14:08:12 +0000]
fixed the random function

12 years agoadded a nl2br filter
Fabien Potencier [Sun, 18 Dec 2011 11:28:42 +0000]
added a nl2br filter

12 years agoadded missing documentation for the random function
Fabien Potencier [Sun, 18 Dec 2011 11:16:35 +0000]
added missing documentation for the random function

12 years agoadded a random function
Fabien Potencier [Sun, 18 Dec 2011 10:24:52 +0000]
added a random function

12 years agoadded a way to change the default format for the date filter
Fabien Potencier [Sun, 18 Dec 2011 10:12:38 +0000]
added a way to change the default format for the date filter

12 years agomerged branch arnaud-lb/ext-crash2 (PR #560)
Fabien Potencier [Sat, 17 Dec 2011 07:58:24 +0000]
merged branch arnaud-lb/ext-crash2 (PR #560)

Commits
-------

9e6f285 fixed crash in twig_template_get_attributes when input is not an array or object

Discussion
----------

Fix crash in twig_template_get_attributes when input is not an array or object

This fixes a crash when the input of twig_template_get_attributes() is not an array or object, and strict mode is enabled.

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

by nikic at 2011/12/16 12:03:21 -0800

Could you maybe place the exception tests in a different method?

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

by arnaud-lb at 2011/12/16 12:13:35 -0800

This method already expects many of its inputs to cause an exception to be thrown (it tests getAttribute() in strict mode, and in many cases the attribute isn't defined). I don't see a real benefit from moving these tests in a separate method in this case.

12 years agofixed crash in twig_template_get_attributes when input is not an array or object
Arnaud Le Blanc [Thu, 15 Dec 2011 19:54:24 +0000]
fixed crash in twig_template_get_attributes when input is not an array or object

12 years agoupdated NetBeans plugin URL
Fabien Potencier [Fri, 16 Dec 2011 15:05:09 +0000]
updated NetBeans plugin URL

12 years agomerged branch arnaud-lb/ext-crash (PR #558)
Fabien Potencier [Sun, 11 Dec 2011 15:53:52 +0000]
merged branch arnaud-lb/ext-crash (PR #558)

Commits
-------

c920344 code style
50da1a2 don't modify function name

Discussion
----------

Fix crash in extension

This fixes a crash caused by `php_strtolower()` modifying its input. (Crashes on amd64, but not on x86 for me.)

12 years agocode style
Arnaud Le Blanc [Sat, 10 Dec 2011 13:49:52 +0000]
code style

12 years agodon't modify function name
Arnaud Le Blanc [Sat, 10 Dec 2011 13:48:20 +0000]
don't modify function name

12 years agomerged branch JEDIBC/master (PR #556)
Fabien Potencier [Fri, 9 Dec 2011 09:27:23 +0000]
merged branch JEDIBC/master (PR #556)

Commits
-------

3bb822e . misspell function _twig_convert_encoding -> twig_convert_encoding

Discussion
----------

misspell function _twig_convert_encoding -> twig_convert_encoding

Located in _twig_escape_js_callback, the function call was misspelled and raised a PHP Fatal error:  Call to undefined function _twig_convert_encoding() in ~/www/project/vendors/Twig/Extension/Core.php on line 585

12 years ago. misspell function _twig_convert_encoding -> twig_convert_encoding
JEDIBC [Fri, 9 Dec 2011 09:08:13 +0000]
. misspell function _twig_convert_encoding -> twig_convert_encoding

12 years agomoved some common compiled code to Twig_Template
Fabien Potencier [Thu, 8 Dec 2011 18:14:07 +0000]
moved some common compiled code to Twig_Template

12 years agofixed the lexer when an operator ending with a letter ends a line
Fabien Potencier [Thu, 8 Dec 2011 08:29:20 +0000]
fixed the lexer when an operator ending with a letter ends a line

12 years agoadded Twig C extension version in phpinfo
Fabien Potencier [Wed, 7 Dec 2011 11:18:20 +0000]
added Twig C extension version in phpinfo

12 years agomoved regexes in the lexer to their own array
Fabien Potencier [Wed, 7 Dec 2011 10:05:06 +0000]
moved regexes in the lexer to their own array

12 years agoadded documentation for the new string interpolation feature
Fabien Potencier [Wed, 7 Dec 2011 10:01:05 +0000]
added documentation for the new string interpolation feature

12 years agomerged branch arnaud-lb/str-interpolation (PR #515)
Fabien Potencier [Wed, 7 Dec 2011 09:09:34 +0000]
merged branch arnaud-lb/str-interpolation (PR #515)

Commits
-------

d41d10c simplification
2dbb420 moved hard-coded regexes
61986c1 shortcut for non-interpolated double quoted strings
062ed5c regex optimization
0e63abb integration tests for interpolated strings
773fff5 parser tests for interpolated strings
098634e parser support for interpolated strings
c8bba24 lexer tests for interpolated strings
a203686 lexer support for interpolated strings
0bd63dd stack lexer states

Discussion
----------

String interpolation syntax

This adds support for string interpolation:

```
{{ "foo #{ any expression here } bar" }}
```

I find string interpolation to be often more readable than concatenation, and doesn't have the precedence ambiguity of the concatenation operator:

```
Interpolation:

{{ "foo #{bar} baz" }}
{{ "foo #{1+2} baz" }}
{{ "foo #{1+2} baz"|escape }}

Concatenation:

{{ "foo "~bar~" baz" }}
{{ "foo "~(1+2)~" baz" }} extra parentheses
{{ ("foo "~(1+2)~" baz")|escape }} more extra parentheses
```

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

by nikic at 2011/11/12 12:41:54 -0800

Really nice idea. We should discuss the exact syntax though :) Dart for example uses `${expr}` for interpolation or `$name` if the expression is just a name. I think it makes sense to have a special short syntax for the name case, because it is the most common one.

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

by stof at 2011/11/12 13:06:51 -0800

@nikic could you comment on the PR instead of commenting on each commit individually ? it would make it easier to see what is concerned in the PR.

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

by arnaud-lb at 2011/11/12 14:22:14 -0800

@nikic Thanks for your review, I'll take care of your remarks.

For the syntax, I have no preference. I've taken this one because it has the same semantics. In Ruby and Coffeescript the `#{...}` allows any expression between the brackets. In PHP the expression in the `${...}` must start with a variable name. As you mentioned Dart's `${...}` seems to allow any expression.

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

by nikic at 2011/11/12 15:03:48 -0800

@arnaud-lb If Ruby and Coffeescript use this, the #{...} syntax should be okay. Especially as ${...} might be confusing for PHP developers as it has the semantics of variable variables in PHP.

@stof Thanks, will do so next time.

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

by damianb at 2011/11/12 15:38:31 -0800

@stof he doesn't need to - this is something github handles already. in the PR view, beside the "@nikic commented" bits, there's a set of links that shows where exactly the comment was in the format of commit sha, filename, and line inside the diff.

You can see for yourself right here, upper left:
![pr snapshot](http://i42.tinypic.com/zl6s82.png)

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

by stof at 2011/11/13 01:20:38 -0800

@damianb The comment appears, but not the context in which the comment was. We have to follow each link to see it whereas comments done on the PR appear directly with their context. This is why I said it is easier when comments are on the PR.

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

by nikic at 2011/12/02 15:13:30 -0800

So what about this now?

Btw, `REGEX_STRING` and `REGEX_DQ_STRING_PART` still are hardcoded and do not depend on the specified `interpolation` tags. But this looks hard to change, at least the regexes are quite complicated.

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

by arnaud-lb at 2011/12/02 15:22:45 -0800

I think I've addressed all issues (except hardcoding of `#{` and `}` in `REGEX_STRING` and `REGEX_DQ_STRING_PART`.)

Can this be merged after v1.4 is release if the syntax is accepted ?

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

by nikic at 2011/12/03 01:53:41 -0800

This would be my go for `STRING` and `DQ_STRING_PART` (isn't tested):

```php
<?php
$interpolChar = preg_quote(substr($options['interpolation'][0], 0, 1), '/');
$interpolPart = '[^' . $interpolChar . '"\\\\]*';
if (strlen($options['interpolation'][0]) > 1) {
    $interpolRest = preg_quote(substr($options['interpolation'][0], 1), '/');
    $interpolRegex = $interpolPart . '(?:(?:\\\\.|' . $interpolChar . '(?!' . $interpolRest . '))' . $interpolPart . ')*';

} else {
    $interpolRegex =  $interpolPart . '(?:\\\\.' . $interpolPart . ')*';
}
$this->options['dq_string_part_regex'] = '/' . $interpolRegex . '/As';
$this->options['string_regex'] = '/"' . $interpolRegex . '"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As';
```

It should allow both a single char interpolation syntax (like `{`) and multichar ones (like `#{`).

By the way, could we maybe move the compiled regexes out of `$this->options` into `$this->regexes`?

12 years agoadded the CHANGELOG to the PEAR package
Fabien Potencier [Wed, 7 Dec 2011 08:58:16 +0000]
added the CHANGELOG to the PEAR package

12 years agoenhanced exceptions for unknown filters, functions, tests, and tags
Fabien Potencier [Wed, 7 Dec 2011 07:51:22 +0000]
enhanced exceptions for unknown filters, functions, tests, and tags

12 years agoremoved dead code
Fabien Potencier [Wed, 7 Dec 2011 08:31:08 +0000]
removed dead code

12 years agoadded a way to get all registered tags
Fabien Potencier [Wed, 7 Dec 2011 08:23:10 +0000]
added a way to get all registered tags

12 years agoRemoved trailing white spaces
Jonathan Ingram [Mon, 5 Dec 2011 01:43:41 +0000]
Removed trailing white spaces

12 years agoHelp the developer when they specify an invalid function by providing some alternatives
Jonathan Ingram [Mon, 5 Dec 2011 00:47:40 +0000]
Help the developer when they specify an invalid function by providing some alternatives

12 years agomerged branch jonathaningram/patch-1 (PR #549)
Fabien Potencier [Wed, 7 Dec 2011 07:19:37 +0000]
merged branch jonathaningram/patch-1 (PR #549)

Commits
-------

989bb22 Removed trailing white spaces
f880bab Help the developer when they specify an invalid filter by providing some alternatives

Discussion
----------

Help the developer when they specify an invalid filter by providing some...

... alternatives.

Bug fix: no
Feature addition: yes
Backwards compatibility break: no

Uses a simple `strpos` search (no fancy diff to determine what the filter could be). There is no impact to runtime performance because this is all happening during template compilation.

Examples:

```jinja
{{ my_entity|json }}
```

Shows exception:

`The filter "json" does not exist. Did you mean "json_encode"?`

```jinja
{{ my_date|dat }}
```

Shows:

`The filter "dat" does not exist. Did you mean "date"?`

```jinja
{{ my_var|f }}
```

Shows:

`The filter "f" does not exist. Did you mean "format", "default", "_default", "format_args", "format_args_as_text", "file_excerpt", "format_file", "format_file_from_text", "file_link"?`

Also good for custom filters created in your own domain `st_`:

```jinja
{{ my_var|st_ }}
```

Shows:

`The filter "st_" does not exist. Did you mean "st_friendly_date", "st_site_test_url"?`

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

by stof at 2011/12/04 16:34:27 -0800

I like the idea to provide help to the developer in case of error. You should probably do the same for functions

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

by Tobion at 2011/12/05 05:56:29 -0800

+1 for a combination of string starts with (suggesting domain specific filters, e.g. st_*) and levenshtein for typos

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

by chucktrukk at 2011/12/05 08:13:10 -0800

+1. This would be really helpful.

12 years agobumped version to 1.5.0-DEV
Fabien Potencier [Wed, 7 Dec 2011 07:11:23 +0000]
bumped version to 1.5.0-DEV

12 years agoprepared the 1.4.0 release
Fabien Potencier [Wed, 7 Dec 2011 07:09:57 +0000]
prepared the 1.4.0 release

12 years agoadded a unit test test for previous merge
Fabien Potencier [Tue, 6 Dec 2011 15:54:00 +0000]
added a unit test test for previous merge

12 years agomerged branch duo-criativa/master (PR #544)
Fabien Potencier [Tue, 6 Dec 2011 15:49:24 +0000]
merged branch duo-criativa/master (PR #544)

Commits
-------

11b8689 Refactoring: using && instead of nested if's
7aa6757 Bug correction: Parsing integers large than PHP_INT_MAX was generating trucated token values.
046e4ff Bug correction: Parsing integers large than PHP_INT_MAX was generating trucated token values.

Discussion
----------

Fixed bug that was trucating integers large then PHP_INT_MAX

The following code

{% set sizes = [7077888, 4529848322899102924818554258718729223372036854775807] %}
{% for i in sizes %}
   {{ i }}
{% endfor %}

was generating the following output

7077888
452984832
2147483647
2147483647
2147483647

With the fix, the output looks like the following on Ubuntu 11.04

7077888
452984832
28991029248
1855425871872
9.2233720368548E+18

12 years agoRemoved trailing white spaces
Jonathan Ingram [Mon, 5 Dec 2011 01:45:22 +0000]
Removed trailing white spaces

12 years agoHelp the developer when they specify an invalid filter by providing some alternatives
Jonathan Ingram [Mon, 5 Dec 2011 00:01:25 +0000]
Help the developer when they specify an invalid filter by providing some alternatives

12 years agoadded missing preserveKeys argument to the reverse filter
Fabien Potencier [Sat, 3 Dec 2011 07:37:53 +0000]
added missing preserveKeys argument to the reverse filter

12 years agofixed macros containing filter tag calls
Fabien Potencier [Sat, 3 Dec 2011 07:16:26 +0000]
fixed macros containing filter tag calls

12 years agomerged branch hason/arrayloader (PR #542)
Fabien Potencier [Fri, 2 Dec 2011 14:11:24 +0000]
merged branch hason/arrayloader (PR #542)

Commits
-------

16d7800 fixed a crash when an object with __toString() method is passed as template name

Discussion
----------

fixed a crash when an object with __toString() method is passed as templ...

...ate name

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

by fabpot at 2011/12/01 03:58:47 -0800

Not sure about this one as the phpdoc clearly state that the name is a string. Do you have a specific user case in mind?

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

by hason at 2011/12/01 04:26:47 -0800

I use the class "Twig_Loader_Chain" as template loader in Symfony2 application. One of the embeded loaders is "Twig_Loader_Array". In Symfony2 is used "Symfony\Component\Templating\TemplateReferenceInterface" for internal representation of a template and it causes a crash.

12 years agoRefactoring: using && instead of nested if's
Paulo Roberto Ribeiro [Thu, 1 Dec 2011 22:18:58 +0000]
Refactoring: using && instead of nested if's

12 years agoBug correction: Parsing integers large than PHP_INT_MAX was generating trucated token...
Paulo Roberto Ribeiro [Thu, 1 Dec 2011 20:41:28 +0000]
Bug correction: Parsing integers large than PHP_INT_MAX was generating trucated token values.

12 years agoBug correction: Parsing integers large than PHP_INT_MAX was generating trucated token...
Paulo Roberto Ribeiro [Thu, 1 Dec 2011 19:54:23 +0000]
Bug correction: Parsing integers large than PHP_INT_MAX was generating trucated token values.

12 years agofixed a crash when an object with __toString() method is passed as template name
Martin Hasoň [Thu, 1 Dec 2011 11:43:07 +0000]
fixed a crash when an object with __toString() method is passed as template name

12 years agofixed markup in doc
Fabien Potencier [Tue, 29 Nov 2011 14:49:51 +0000]
fixed markup in doc

12 years agoprepared the 1.4.0-RC2 release
Fabien Potencier [Sun, 27 Nov 2011 19:32:27 +0000]
prepared the 1.4.0-RC2 release

12 years agomerged branch arnaud-lb/twig-escape-filter-opt (PR #537)
Fabien Potencier [Sun, 27 Nov 2011 15:46:10 +0000]
merged branch arnaud-lb/twig-escape-filter-opt (PR #537)

Commits
-------

7b8d476 optimized twig_escape_filter

Discussion
----------

Optimized twig_escape_filter

This optimizes the part of twig_escape_filter that checks if the charset is supported by htmlspecialchars.

This uses a static variable to avoid initializing the charsets array each time the function is called; and does a hash lookup instead of array search (saves a function call too).

The optimized version takes 66% less time that the original version on html escaping :) (no difference on js escaping).

12 years agooptimized twig_escape_filter
Arnaud Le Blanc [Sun, 27 Nov 2011 15:13:43 +0000]
optimized twig_escape_filter

uses a static variable to avoid initializing the charsets array each
time the function is called; and does a hash lookup instead of array
search (saves a function call too).

12 years agosimplified the implementation of the replace filter
Fabien Potencier [Sun, 27 Nov 2011 13:58:28 +0000]
simplified the implementation of the replace filter

12 years agofixed a crash under certain versions of PHP when an object with a __toString() method...
Fabien Potencier [Fri, 25 Nov 2011 18:36:25 +0000]
fixed a crash under certain versions of PHP when an object with a __toString() method is used with htmlspecialchars

12 years agorenamed an internal class
Fabien Potencier [Wed, 23 Nov 2011 22:45:02 +0000]
renamed an internal class

12 years agomade a small speed optimization
Fabien Potencier [Wed, 23 Nov 2011 14:18:40 +0000]
made a small speed optimization

12 years agofixed unit tests due to a difference between the PHP and C versions of Twig_Template...
Fabien Potencier [Wed, 23 Nov 2011 13:24:45 +0000]
fixed unit tests due to a difference between the PHP and C versions of Twig_Template::getAttribute()

12 years agomerged branch arnaud-lb/ext (PR #530)
Fabien Potencier [Wed, 23 Nov 2011 13:14:41 +0000]
merged branch arnaud-lb/ext (PR #530)

Commits
-------

569f782 fix ZTS build
1606910 Fix undefined behavior
0ce8d3c Convert item argument to string
d807981 don't try to access non public property or method
7e566b8 test twig_template_get_attributes

Discussion
----------

twig_template_get_attributes tests and fixes

This enables testing of twig_template_get_attributes (every TemplateTest test is ran against twig_template_get_attributes too) and fixes some bugs I've found.

There is still 3 failing tests due to a difference of how twig_template_get_attributes and Twig_Template::getAttribute use Twig_Template::$cache.

Twig_Template::getAttribute doesn't cache properties, and twig_template_get_attributes expects $cache[$class]['properties'] to be set if $cache[$class] is set. So twig_template_get_attributes can fail if the cache is already populated by Twig_Template::getAttribute.

12 years agofix ZTS build
Arnaud Le Blanc [Wed, 23 Nov 2011 13:01:51 +0000]
fix ZTS build

12 years agoFix undefined behavior
Arnaud Le Blanc [Wed, 23 Nov 2011 11:38:55 +0000]
Fix undefined behavior

The callbacks are expected to return an integer, and returning void
instead was triggering weird bugs

I've also removed the casts to ensure that the signatures are compatible

12 years agoConvert item argument to string
Arnaud Le Blanc [Tue, 22 Nov 2011 22:11:21 +0000]
Convert item argument to string

This fixes a crash in some cases and repeated conversions

12 years agodon't try to access non public property or method
Arnaud Le Blanc [Tue, 22 Nov 2011 20:58:47 +0000]
don't try to access non public property or method