Commit Graph

1167 Commits

Author SHA1 Message Date
Fabien Potencier 4b8a0e5e7a added missing doc for the do tag 2011-12-26 11:21:22 +01:00
Fabien Potencier a9aeea41d2 fixed typo 2011-12-26 11:17:02 +01:00
Fabien Potencier f3de043d0e changed hash key expression support (expression must now be enclosed with parentheses and hash keys can now be names) 2011-12-26 09:35:38 +01:00
Fabien Potencier 0d48b6d19d 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
2011-12-26 09:08:00 +01:00
Eugene Serkin fd78ec0bf1 Fixed PhpDoc for Twig_TokenParserInterface and all other TokenParsers 2011-12-26 01:55:03 +02:00
Fabien Potencier b7de8e40c8 added convenience methods to manipulate an array node 2011-12-25 22:34:12 +01:00
Fabien Potencier 591f982b47 Revert "Revert "merged branch arnaud-lb/hash-key-expr (PR #514)""
This reverts commit 99b2c5bf99.
2011-12-24 09:22:35 +01:00
Fabien Potencier 941ce5b672 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)
2011-12-23 11:29:22 +01:00
Javier Eguíluz 7194b1adaa Added a notice in the nl2br filter documentation about the proper Twig version to use it 2011-12-23 10:26:49 +01:00
Fabien Potencier 99b2c5bf99 Revert "merged branch arnaud-lb/hash-key-expr (PR #514)"
This reverts commit 8665c64634, reversing
changes made to 4aba337cda.
2011-12-23 08:59:54 +01:00
Fabien Potencier a555faec40 updated doc 2011-12-22 22:48:48 +01:00
Fabien Potencier ad0b8f0900 updated CHANGELOG 2011-12-22 22:42:44 +01:00
Fabien Potencier 8665c64634 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.
2011-12-22 22:41:37 +01:00
Fabien Potencier 4aba337cda added a do tag (closes #446) 2011-12-22 22:36:35 +01:00
Fabien Potencier 5ae6e13aac added doc for the flush tag 2011-12-22 19:32:51 +01:00
Fabien Potencier 95b97eb8da added IDE support for Coda in the doc (closes #566) 2011-12-22 19:25:03 +01:00
Fabien Potencier 46a064d006 tweaked doc (closes #567) 2011-12-22 14:20:20 +01:00
Fabien Potencier c95fe91fc8 replaced zend_error_noreturn calls to zend_error as zend_error_noreturn is not exported (closes #554) 2011-12-22 14:17:59 +01:00
Fabien Potencier fc778405ff 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.
2011-12-21 20:27:52 +01:00
Fabien Potencier 26453bffcf fixed typo 2011-12-21 20:17:43 +01:00
Arnaud Le Blanc b26d69af38 removed bogus TSRMLS_CCs 2011-12-21 19:52:05 +01:00
Fabien Potencier 1d6dfad4f5 added a flush tag 2011-12-21 19:34:14 +01:00
Fabien Potencier 2d21619ddc 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.
2011-12-21 11:25:50 +01:00
nikic 8255b8b239 Fix test for previous commit 2011-12-21 11:06:03 +01:00
nikic 834ce4c641 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)
2011-12-21 11:06:00 +01:00
Fabien Potencier 6f020ccaf4 fixed dump when xdebug.overload_var_dump is not defined in php.ini 2011-12-18 20:54:12 +01:00
Fabien Potencier 4f19c7a04b added support for dynamically named filters and functions 2011-12-18 20:20:35 +01:00
Fabien Potencier 9489136c17 made the dump function registration explicit and disable its output when debug is off 2011-12-18 20:20:35 +01:00
Fabien Potencier 3793740ac5 fixed dump function when the context contains Twig_Template instances 2011-12-18 20:20:35 +01:00
Fabien Potencier 865a7039f8 added a dump function to help debugging templates 2011-12-18 18:30:06 +01:00
Fabien Potencier 11943fbe21 fixed the random function 2011-12-18 15:08:12 +01:00
Fabien Potencier 932a4d8d94 added a nl2br filter 2011-12-18 12:36:07 +01:00
Fabien Potencier 2928191769 added missing documentation for the random function 2011-12-18 12:16:35 +01:00
Fabien Potencier 89a1519e09 added a random function 2011-12-18 11:27:47 +01:00
Fabien Potencier f8b7441e42 added a way to change the default format for the date filter 2011-12-18 11:12:59 +01:00
Fabien Potencier b990868012 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.
2011-12-17 08:58:24 +01:00
Arnaud Le Blanc 9e6f285362 fixed crash in twig_template_get_attributes when input is not an array or object 2011-12-16 20:46:37 +01:00
Fabien Potencier 85a7a5e8e9 updated NetBeans plugin URL 2011-12-16 16:05:09 +01:00
Fabien Potencier 972a93f85d 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.)
2011-12-11 16:53:52 +01:00
Arnaud Le Blanc c9203442c5 code style 2011-12-10 14:49:52 +01:00
Arnaud Le Blanc 50da1a2881 don't modify function name 2011-12-10 14:48:20 +01:00
Fabien Potencier 7359f7c956 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
2011-12-09 10:27:23 +01:00
JEDIBC 3bb822ec2f . misspell function _twig_convert_encoding -> twig_convert_encoding 2011-12-09 10:08:13 +01:00
Fabien Potencier 3689745d35 moved some common compiled code to Twig_Template 2011-12-08 19:14:07 +01:00
Fabien Potencier ae250f6b6f fixed the lexer when an operator ending with a letter ends a line 2011-12-08 09:29:20 +01:00
Fabien Potencier b496a2324c added Twig C extension version in phpinfo 2011-12-07 12:18:20 +01:00
Fabien Potencier 822fe3fa19 moved regexes in the lexer to their own array 2011-12-07 11:07:02 +01:00
Fabien Potencier 6e2d7ba1b9 added documentation for the new string interpolation feature 2011-12-07 11:03:00 +01:00
Fabien Potencier 1036f90e79 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`?
2011-12-07 10:09:34 +01:00
Fabien Potencier fd7b34ee78 added the CHANGELOG to the PEAR package 2011-12-07 09:58:16 +01:00