This PR was merged into the 3.x branch.
Discussion
----------
Deprecate Twig\ExpressionParser::parseOnlyArguments() and Twig\ExpressionParser::parseArguments()
Commits
-------
960f6762ed Deprecate Twig\ExpressionParser::parseOnlyArguments() and Twig\ExpressionParser::parseArguments()
This PR was merged into the 3.x branch.
Discussion
----------
Add a note on the types locality
For your information `@drjayvee` `@ruudk`
Commits
-------
e7ae984e36 Add a note on the types locality
This PR was merged into the 3.x branch.
Discussion
----------
Add `getLastModified()` to extensions
Give to extensions the ability to set a last modification date for cache invalidation.
### Runtime
Currently, the cache is not invalidated when the signature of a runtime method is modified. This is an issue for templates that use named arguments, as argument names have an impact on the generated class.
With this change, extensions using runtime classes can compute a modification date by including the files on which they depend.
By default, the `AbstractExtension` checks if there is a file for the runtime class with the same name of the
This is the convention applied in [Symfony](https://github.com/symfony/symfony/tree/7.3/src/Symfony/Bridge/Twig/Extension) and Twig Extra: `MarkdownExtension` has `MarkdownRuntime`.
### Attribute
Contributing to https://github.com/twigphp/Twig/pull/3916.
The extension class that will get the configuration from attributes will be able to track the classes having attributes to find the last modification date of all this classes.
### ~BC break~
~In Twig 4.0, the method `getLastModified` will be added to `ExtensionInterface`. It is extremely rare to implement this interface without extending `AbstractExtension`. So adding this method to the interface shouldn't be a problem as the base class has an implementation.~
Commits
-------
d8fe3bd1ec Add `LastModifiedExtensionInterface` and implementation in `AbstractExtension` to track modification of runtime classes
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
[Doc] Update the docs about attribute() function
I Was fixing `filter` -> `function` error, but I realized that we could expand the docs of `attribute()` a bit, even if it's deprecated 🙏
Commits
-------
84daad9a27 [Doc] Update the docs about attribute() function
This PR was merged into the 3.x branch.
Discussion
----------
Add a way to stream template rendering
Even if we're using `yield` internally, there is no easy way to stream template rendering. This new method can be used like this to HTTP stream a template with Symfony:
```php
use Symfony\Component\HttpFoundation\StreamedResponse;
use Twig\Environment;
$twig = new Environment(/* ... */);
$response = new StreamedResponse($twig->load('index')->stream([]));
$response->send();
```
Commits
-------
1915ee2812 Add a way to stream template rendering
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
Support underscores in number literals
```twig
{{ 1000 == 1_000 ? 'yes' : 'no' }}
# now: syntax error
# this PR: "yes"
```
> As of PHP 7.4.0, integer literals may contain underscores (_) between digits, for better readability of literals. These underscores are removed by PHP's scanner.
https://www.php.net/manual/en/language.types.integer.php
This PR replicates that behaviour, using the regexp to match the literals and then remove the "_".
I'm targeting **Twig4** but maybe 3.x would be ok?
I cannot think of a real case that
- does not trigger an error currently
- would work differently after this PR
Commits
-------
da4d96692a Support underscores in number literals
This PR was merged into the 3.x branch.
Discussion
----------
Clarify documentation for escape filter
It was somewhat unclear from the documentation what the intended purpose of the 'js' escape strategy is. I wasn't certain *where* exactly in JavaScript such strings were intended to be output. Someone (by that I mean me--though maybe I'm just an idiot...) might inadvertently think the filter was meant to be used somewhere in actual JavaScript code, rather than simply in strings.
Commits
-------
728b361e9d Clarify documentation for escape filter