web/konrad/twig.git
11 years agoFix extension crash when calling unknown method inside a macro
Charles [Thu, 8 Nov 2012 02:25:27 +0000]
Fix extension crash when calling unknown method inside a macro

11 years agomerged branch nomack84/fixed_typo (PR #891)
Fabien Potencier [Wed, 7 Nov 2012 20:11:21 +0000]
merged branch nomack84/fixed_typo (PR #891)

This PR was merged into the master branch.

Commits
-------

cc65c88 [template_from_string]Fixed typo

Discussion
----------

[template_from_string]Fixed typo in docs

Fix a typo in the template_from_string function docs

11 years ago[template_from_string]Fixed typo
Mario A. Alvarez Garcia [Wed, 7 Nov 2012 19:59:42 +0000]
[template_from_string]Fixed typo

11 years agobumped version to 1.11.0-DEV
Fabien Potencier [Wed, 7 Nov 2012 11:22:35 +0000]
bumped version to 1.11.0-DEV

11 years agoprepared the 1.11.0 release
Fabien Potencier [Wed, 7 Nov 2012 11:20:21 +0000]
prepared the 1.11.0 release

11 years agomerged branch char101/fix-build-warning (PR #886)
Fabien Potencier [Wed, 7 Nov 2012 06:34:36 +0000]
merged branch char101/fix-build-warning (PR #886)

This PR was merged into the master branch.

Commits
-------

3164ee3 Fix build warning for const pointer

Discussion
----------

Fix build warning for const pointer

 Issue #883

11 years agoFix build warning for const pointer
Charles [Wed, 7 Nov 2012 01:49:50 +0000]
Fix build warning for const pointer

11 years agoadded a .gitignore to ignore files created when building the C extension
Fabien Potencier [Tue, 6 Nov 2012 12:20:59 +0000]
added a .gitignore to ignore files created when building the C extension

11 years agomerged branch char101/nativeext-exception-info (PR #885)
Fabien Potencier [Tue, 6 Nov 2012 11:54:36 +0000]
merged branch char101/nativeext-exception-info (PR #885)

This PR was merged into the master branch.

Commits
-------

db13b66 Pass lineno and filename to Twig_Error constructor
feee667 Merge branch 'nativeext-exception-info' of https://github.com/fabpot/Twig into nativeext-exception-info
adb31d4 Call Twig_Error constructor
d4a8c8b added tests for exceptions thrown in Twig_Template::getAttribute()
1b82bf7 Add template filename for the rest of the exception
5675140 Handle NULL filename
71f64bc Add template name to error message

Discussion
----------

Add template name to error message

Issue #884

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

by fabpot at 2012-11-06T07:43:16Z

For some unknown reasons, I don't see your branch when I try to submit a PR. Can you cherry-pick my unit tests from my `nativeext-exception-info` branch?

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

by Tobion at 2012-11-06T08:29:19Z

@char101 Maybe you could also integrate the fixes of #878?

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

by fabpot at 2012-11-06T08:30:55Z

@Tobion Let's do one thing at a time.

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

by char101 at 2012-11-06T08:59:30Z

@Tobion AFAIK, unlike the PHP implementation, the C implementation does not automatically convert array key type.

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

by char101 at 2012-11-06T09:27:54Z

@fabpot How about the lineno variable? Should I just set it to 0 or is there any function that can be called to obtain it?

```php
if (-1 === $this->lineno || null === $this->filename) {
    $this->guessTemplateInfo();
}
```

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

by fabpot at 2012-11-06T09:32:09Z

You need to keep `-1` for the line.

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

by char101 at 2012-11-06T09:36:56Z

If `$lineno` is `-1`, wouldn't `$this->guessTemplateInfo()` still be called?

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

by fabpot at 2012-11-06T09:45:34Z

Yes, but the template name will not be guessed. So, there is a performance overhead for the line guessing, but not for the template name guessing.

11 years agoPass lineno and filename to Twig_Error constructor
Charles [Tue, 6 Nov 2012 09:51:20 +0000]
Pass lineno and filename to Twig_Error constructor

11 years agoMerge branch 'nativeext-exception-info' of https://github.com/fabpot/Twig into native...
Charles [Tue, 6 Nov 2012 08:51:54 +0000]
Merge branch 'nativeext-exception-info' of https://github.com/fabpot/Twig into nativeext-exception-info

11 years agoCall Twig_Error constructor
Charles [Tue, 6 Nov 2012 08:50:00 +0000]
Call Twig_Error constructor

11 years agoadded tests for exceptions thrown in Twig_Template::getAttribute()
Fabien Potencier [Tue, 6 Nov 2012 07:39:44 +0000]
added tests for exceptions thrown in Twig_Template::getAttribute()

11 years agoAdd template filename for the rest of the exception
Charles [Tue, 6 Nov 2012 04:37:50 +0000]
Add template filename for the rest of the exception

11 years agoHandle NULL filename
Charles [Tue, 6 Nov 2012 04:16:51 +0000]
Handle NULL filename

11 years agoAdd template name to error message
Charles [Tue, 6 Nov 2012 04:02:59 +0000]
Add template name to error message

11 years agofixed macro compilation when a variable name is a PHP reserved keyword (closes #881)
Fabien Potencier [Mon, 5 Nov 2012 07:50:56 +0000]
fixed macro compilation when a variable name is a PHP reserved keyword (closes #881)

11 years agofixed CS
Fabien Potencier [Sat, 3 Nov 2012 07:27:23 +0000]
fixed CS

11 years agomerged branch fabpot/timezones (PR #876)
Fabien Potencier [Sat, 3 Nov 2012 07:09:43 +0000]
merged branch fabpot/timezones (PR #876)

This PR was merged into the master branch.

Commits
-------

f99504a changed the date filter behavior to always apply the default timezone, except if false is passed as the timezone
d3b0cbd merged branch jmikola/patch-1 (PR #845)
a6a1ef0 Avoid setting timezones on DateIntervals

Discussion
----------

changed the date filter behavior to always apply the default timezone, except if false is passed as the timezone

This PR is based on #845, and addresses issue #778.

Right now, the timezone management when using the date filter is counter-intuitive. When you pass a DateTime object, the default timezone is not applied, but in all other cases, it is.

This PR makes the behavior more consistent by always applying the default timezone (which is probably what users want most of the time), and this can be disabled by explicitly passing ``false`` as the timezone value.

This is a BC break but I think that not many consciously rely on the current behavior.

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

by fabpot at 2012-10-30T15:49:13Z

@jmikola Can you have a look at this PR and tell me your opinion about this change?

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

by jmikola at 2012-11-02T20:17:30Z

@fabpot: Will take a look at this tonight. I missed the notifications as I was offline for a few days.

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

by jmikola at 2012-11-03T04:09:54Z

I read through all of the issues and PR's and this looks reasonable. Are we missing a test case for passing in a DateTime object with `false` for the timezone? I do see one example where we render the current date using the `'e'` format string and provide `false` for the timezone, but that's it.

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

by fabpot at 2012-11-03T07:09:08Z

ok, I've added an additional test just to be sure.

11 years agochanged the date filter behavior to always apply the default timezone, except if...
Fabien Potencier [Tue, 30 Oct 2012 09:04:25 +0000]
changed the date filter behavior to always apply the default timezone, except if false is passed as the timezone

11 years agoadded a paragraph in the docs about how the Twig blocks work (based on an explanation...
Fabien Potencier [Tue, 30 Oct 2012 18:13:42 +0000]
added a paragraph in the docs about how the Twig blocks work (based on an explanation from nikic, closes #704, refs #351)

11 years agofixed a stupid test
Fabien Potencier [Tue, 30 Oct 2012 17:12:52 +0000]
fixed a stupid test

11 years agofixed broken test
Fabien Potencier [Tue, 30 Oct 2012 16:46:49 +0000]
fixed broken test

11 years agofixed bitwise operator precedences (closes #866)
Fabien Potencier [Tue, 30 Oct 2012 16:40:52 +0000]
fixed bitwise operator precedences (closes #866)

11 years agomerged branch fabpot/template_from_string (PR #874)
Fabien Potencier [Tue, 30 Oct 2012 15:42:59 +0000]
merged branch fabpot/template_from_string (PR #874)

This PR was merged into the master branch.

Commits
-------

4599188 added the template_from_string function

Discussion
----------

added the template_from_string function

One of the most often asked question is how someone can evaluate a template string from a template.

The template_from_string function solves this problem (more in the included docs).

I have two questions before merging this:

 * What about the name? I find it quite long but also readable (`{% include template_from_string(template) %}`).

 * Does it belongs to Twig core?

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

by boutell at 2012-10-28T16:45:08Z

Interesting. What are the use cases? Would it cache in some way, the md5 of the string maybe, to avoid having this be a major performance hit on every use?

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

by gcoguiec at 2012-10-28T16:46:04Z

And what about include_from_string ?

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

by lsmith77 at 2012-10-28T16:46:35Z

Heh, was just going to ask the same thing, would a use case be loading a twig snippet from a database? something like https://github.com/symfony-cmf/ContentBundle/issues/8 ..

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

by stof at 2012-10-28T16:48:09Z

@gcoguiec It is not including anything but creating a Twig_Template instance. ``{% extends include_from_string(foo) %}`` would be very ugly.

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

by gruzilla at 2012-10-28T16:48:37Z

i'd say yes.
im not like the core must can do everything. but besides that, what are the reasons against it?
i can already think of some usecases: user defined dynamic templates, ...

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

by alexandresalome at 2012-10-28T16:49:34Z

IMHO it's a mistake to put it in Twig. People won't get how to use it. My reasons are also regarding cache: will the template be regenerated on each call?

Looks magic

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

by stof at 2012-10-28T16:50:06Z

@fabpot I'm not really sure this should be in the core.
But FYI, there is a [PR on your Twig-extensions repository](https://github.com/fabpot/Twig-extensions/pull/68) adding an ``eval`` function with the same goal (but an incomplete implementation)

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

by fabpot at 2012-10-28T16:51:00Z

The template is loaded like any other ones, so it is using the cache if you have configured it. No magic included!

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

by fabpot at 2012-10-28T16:52:44Z

@lsmith77 yes, that's the main use case.

You can also have a look at this thread on the mailing-list: https://groups.google.com/group/twig-devs/browse_thread/thread/a8b7bbae31cade18

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

by fabpot at 2012-10-28T16:54:28Z

I forgot to say that we can also move this function into its own extension, so that enabling it would have to come from a conscious choice from the developer (like the debug function in the debug extension).

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

by lsmith77 at 2012-10-28T16:55:32Z

OK great. Looks like something the CMF will need then. But it would also work for us if its part of the twig extension repo. we could of course also just drop the code into https://github.com/symfony-cmf/CoreBundle/blob/master/Twig/TwigExtension.php

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

by fabpot at 2012-10-28T16:56:59Z

I have proposed it for inclusion in Twig core (but not necessarily in the core extension) as it seems to be something many developers want to do in their code (mainly people writing a CMS in top of Twig).

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

by dlsniper at 2012-10-28T17:05:45Z

Hi

- why not name it `template_string` or `string_template`? Then it would read like: ` {% include template_string(template) %} ` or ` {% include string_template(template) %} `

- imo this shouldn't be in the core but rather in the extensions part of Twig as you just extend existing Twig functionality :)

Cheers.

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

by fabpot at 2012-10-28T17:37:12Z

I've moved the function to a new extension that should be enabled explicitely.

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

by EvanK at 2012-10-28T18:05:57Z

I would love to see this as a built-in feature to Twig, as my coworkers & I have had to implement a workaround for something similar.

(Our workaround involved writing said string to a file named after an md5 of the string's content, and then calling render() on said file, all within the php userspace. It was less than elegant, but functional.)

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

by Crell at 2012-10-28T19:11:34Z

This would lend itself to some of the wacky stuff Drupal has been discussing, too.  +1 on the feature.  No opinion on the name.

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

by jorgelbg at 2012-10-28T20:45:37Z

+1 for built-in support i think this is something Twig should do out of the box, regarding the name I guess that I'll vote for this name ```{% include from_string(template) %}``` The only thing that you can include is a template righ? So why put this explicitly in the function's name?

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

by pylebecq at 2012-10-29T09:53:05Z

+1 for me. And for the name, it seems I'm the only one but I would have vote for `eval` :smiling_imp:

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

by sstok at 2012-10-29T10:14:25Z

eval is bad name as can be confused with eval() in PHP, aka that what is passed is treated as PHP (similar to embeded PHP in Smarty). Please don't..

+1 for as it is now.

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

by drak at 2012-10-29T17:25:24Z

Love it +1

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

by acasademont at 2012-10-30T12:02:40Z

Very useful feature! +1

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

by acasademont at 2012-10-30T12:20:46Z

For clarification, now if you wanted to make dynamic include or dynamic inheritance like this ```{% extends some_var %}``` you had to supply a valid Twig_Template object. Now with this function you can supply a simple string that will be evaluated and transformed into a Twig_Template object. So this PR is not inventing dynamic inheritance but providing a helper to make it easier. Am I right?

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

by stof at 2012-10-30T12:45:08Z

@acasademont no. It is provinding a way to evaluate a string stored somewhere (in a database for instance) as a template. It is not about making dynamic inheritance easier.
If your template can be loaded by your loader (for instance a file when using the Twig_Loader_Filesystem), you can use the template name in your variable for the dynamic inheritance. You are not required to build the Twig_Template instance yourself

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

by fabpot at 2012-10-30T12:53:02Z

When you have `{% extends some_var %}`, `some_var` must be the template name. Using `{% extends template_from_string(some_var) %}` means that `some_var` contains the parent template code.

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

by acasademont at 2012-10-30T13:15:37Z

Perfectly understood, thanks!

11 years agoadded a note about double-escaping when using a variable for the strategy (closes...
Fabien Potencier [Tue, 30 Oct 2012 09:25:30 +0000]
added a note about double-escaping when using a variable for the strategy (closes #868)

11 years agomerged branch jmikola/patch-1 (PR #845)
Fabien Potencier [Tue, 30 Oct 2012 08:57:52 +0000]
merged branch jmikola/patch-1 (PR #845)

This PR was merged into the master branch.

Commits
-------

a6a1ef0 Avoid setting timezones on DateIntervals

Discussion
----------

Avoid setting timezones on DateIntervals

Edit: originally, I opened this to ensure the default Twig timezone was always set on incoming DateTime objects, but I came to realize why that behavior would be undesirable. The idea was prompted by this line from: http://twig.sensiolabs.org/doc/filters/date.html

> The default timezone can also be set globally by calling `setTimezone()`.

Anyway, I did notice an edge case where the code might call `DateInterval::setTimezone()`, so this PR attempts to correct that. Additionally, I added some tests for passing a DateTimeZone object to the `date` filter.

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

by jmikola at 2012-09-22T17:18:56Z

@fabpot: One question came up as I was looking through this a second time: if `twig_date_converter()` receives a DateTime argument, it will override its timezone regardless of the logic path within (either from the `$timezone` argument, Twig default, or the system default).

At first, I thought that it was redundant for `twig_date_format_filter()` not to utilize `twig_date_converter()`, but it looks like that was a careful decision; otherwise, there'd be no way to display DateTimes with their internal timezone. This PR would remove that functionality, so I need to reconsider.

Having said that, there does appear to be a bug in `twig_date_format_filter()` in that it could end up calling a nonexistent `setTimezone()` method on a DateInterval object. Would it be preferable to throw an exception or simply ignore the `$timezone` argument if the `$date` argument is a DateInterval?

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

by fabpot at 2012-10-30T08:56:31Z

I don't know if not changing the timezone on DateTime object was a conscious/careful decision or not. The documentation is not so clear about that, and there is even a bug report about this behavior: #778.

For consistency, I think we can always set the timezone and allow disabling that by passing `false` for the timezone.

Does it sounds good?

11 years agofixed default timezone usage for the date function (refactor of the previous merge)
Fabien Potencier [Tue, 30 Oct 2012 08:53:04 +0000]
fixed default timezone usage for the date function (refactor of the previous merge)

11 years agomerged branch vitman/patch-1 (PR #871)
Fabien Potencier [Tue, 30 Oct 2012 08:40:23 +0000]
merged branch vitman/patch-1 (PR #871)

This PR was squashed before being merged into the master branch (closes #871).

Commits
-------

b89163d Update lib/Twig/Extension/Core.php

Discussion
----------

Update lib/Twig/Extension/Core.php

Added support for setted default timezone for twig date functions.

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

by henrikbjorn at 2012-10-26T07:19:02Z

This have the same problem as the other PR you created. See php.net/datetime for reference.

11 years agoUpdate lib/Twig/Extension/Core.php
vitman [Thu, 25 Oct 2012 17:44:06 +0000]
Update lib/Twig/Extension/Core.php

11 years agoadded the template_from_string function
Fabien Potencier [Sun, 28 Oct 2012 16:28:55 +0000]
added the template_from_string function

11 years agoadded two new recipes
Fabien Potencier [Sun, 28 Oct 2012 14:30:18 +0000]
added two new recipes

11 years agoadded missing documentation about Twig_Loader_Chain
Fabien Potencier [Sun, 28 Oct 2012 14:19:48 +0000]
added missing documentation about Twig_Loader_Chain

11 years agofixed phpdoc
Fabien Potencier [Sun, 28 Oct 2012 13:36:27 +0000]
fixed phpdoc

11 years agomerged branch jeremymarc/master (PR #873)
Fabien Potencier [Sat, 27 Oct 2012 06:23:19 +0000]
merged branch jeremymarc/master (PR #873)

This PR was merged into the master branch.

Commits
-------

c5d351d cast $name to string ($name can be an object implementing __toString function)

Discussion
----------

Cast $name to string in Loader/Chain.php and Loader/FileSystem.php

related to #603

11 years agocast $name to string ($name can be an object implementing __toString function)
Jeremy Marc [Fri, 26 Oct 2012 22:30:04 +0000]
cast $name to string ($name can be an object implementing __toString function)

11 years agomerged branch fabpot/faster-exceptions (PR #864)
Fabien Potencier [Sat, 20 Oct 2012 12:53:18 +0000]
merged branch fabpot/faster-exceptions (PR #864)

This PR was merged into the master branch.

Commits
-------

2506be1 optimized the way Twig exceptions are managed

Discussion
----------

Optimized the way Twig exceptions are managed

As guessing the template name and the line number of where an error occurred is quite expensive, this is now avoided as much as possible.

~~As a side-effect, it also fixes 822 (@hason can you confirm?).~~

11 years agooptimized the way Twig exceptions are managed
Fabien Potencier [Wed, 17 Oct 2012 17:29:45 +0000]
optimized the way Twig exceptions are managed

As guessing the template name and the line number of where an error
occurred is quite expensive, this is now avoided as much as possible.

11 years agoupdated the docs for the new Twig_ExistsLoaderInterface interface
Fabien Potencier [Fri, 19 Oct 2012 12:36:16 +0000]
updated the docs for the new Twig_ExistsLoaderInterface interface

11 years agorenamed Twig_ExtendedLoaderInterface to Twig_ExistsLoaderInterface
Fabien Potencier [Fri, 19 Oct 2012 12:32:48 +0000]
renamed Twig_ExtendedLoaderInterface to Twig_ExistsLoaderInterface

11 years agomerged branch dlsniper/loader-exception-improvement (PR #841)
Fabien Potencier [Fri, 19 Oct 2012 12:27:33 +0000]
merged branch dlsniper/loader-exception-improvement (PR #841)

This PR was squashed before being merged into the master branch (closes #841).

Commits
-------

08ecb0e Improvements for loader speeds

Discussion
----------

Improvements for loader speeds

This is something started from #822 .

It attempts to improve the speed of the chain loader and rest of the standard loaders by adding a cache level and a ```hasSource()``` method for them in order gain speed.

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

by dlsniper at 2012-09-27T14:56:24Z

Thanks for the feedback, I'll do the changes tonight or during the coming weekend.

As for the utility of the ```::setExtendedErrorHandling()``` function, this saves me about 25% to 40% on the benchkmark Fabien presented in the original ticket.

Thanks!

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

by dlsniper at 2012-09-29T11:34:59Z

I've added some caching for the Chain Loader but it's still a WIP. I'll work more on this in the coming hours.

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

by dlsniper at 2012-09-29T23:10:10Z

I'm getting better values right now that I had before, standing on:
```
0.09
0.07 ... x 1
0.07 ... x 1
```
I've also noticed that if I run the tests from the browser then I'll have an overall slowdown of about 0.10 which I'm not sure from where it comes from. Any pointers before me digging a bit more into Twigs internals.

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

by dlsniper at 2012-10-03T21:31:15Z

@fabpot what's your opinion about this PR?

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

by dlsniper at 2012-10-14T18:26:13Z

@Tobion and @fabpot done and done :)

I'm not sure why the tests are failing on PHP 5.4 as I don't have it installed anywhere.

11 years agoImprovements for loader speeds
Florin Patan [Tue, 18 Sep 2012 19:27:45 +0000]
Improvements for loader speeds

11 years agobumped version to 1.11.0-DEV
Fabien Potencier [Fri, 19 Oct 2012 10:48:39 +0000]
bumped version to 1.11.0-DEV

11 years agoprepared the 1.10.3 release
Fabien Potencier [Fri, 19 Oct 2012 10:45:49 +0000]
prepared the 1.10.3 release

11 years agochanged Node instances line numbers from 0 to 1 in unit tests to better reflect what...
Fabien Potencier [Fri, 19 Oct 2012 06:48:03 +0000]
changed Node instances line numbers from 0 to 1 in unit tests to better reflect what really happens when using Twig

11 years agoupdated CHANGELOG
Fabien Potencier [Thu, 18 Oct 2012 12:01:42 +0000]
updated CHANGELOG

11 years agoreverted BC break
Fabien Potencier [Thu, 18 Oct 2012 11:59:31 +0000]
reverted BC break

11 years agomoved some logic from the sandbox node visitor to the sandbox node
Fabien Potencier [Thu, 18 Oct 2012 07:25:09 +0000]
moved some logic from the sandbox node visitor to the sandbox node

11 years agofixed wrong exception class in the filesystem loader
Fabien Potencier [Thu, 18 Oct 2012 06:34:35 +0000]
fixed wrong exception class in the filesystem loader

11 years agofixed wrong template location in error messages (closes #803)
Fabien Potencier [Wed, 17 Oct 2012 17:24:30 +0000]
fixed wrong template location in error messages (closes #803)

11 years agoadded missing version info in the docs for the split filter
Fabien Potencier [Thu, 18 Oct 2012 06:20:20 +0000]
added missing version info in the docs for the split filter

11 years agofixed previous merge
Fabien Potencier [Tue, 16 Oct 2012 12:38:15 +0000]
fixed previous merge

11 years agomerged branch innsand/split-filter_fix (PR #811)
Fabien Potencier [Tue, 16 Oct 2012 12:33:18 +0000]
merged branch innsand/split-filter_fix (PR #811)

This PR was merged into the master branch.

Commits
-------

d5df200 * bug fixes. * str_split on empty delimeter. * tests and documentation updated.
e3c201a Added "split" filter aka explode.

Discussion
----------

Split filter fix

Modification of request #621:
str_split, bug fixes

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

by senz at 2012-08-21T05:56:51Z

@fabpot this is squashed and fixed (hopefully) #621

11 years agofixed import doc
Fabien Potencier [Tue, 16 Oct 2012 05:57:52 +0000]
fixed import doc

11 years agobumped version to 1.10.3-DEV
Fabien Potencier [Mon, 15 Oct 2012 08:26:17 +0000]
bumped version to 1.10.3-DEV

11 years agoprepared the 1.10.2 release
Fabien Potencier [Mon, 15 Oct 2012 08:23:34 +0000]
prepared the 1.10.2 release

11 years agofixed macro calls on PHP 5.4
Fabien Potencier [Mon, 15 Oct 2012 08:22:12 +0000]
fixed macro calls on PHP 5.4

11 years agobumped version to 1.10.2-DEV
Fabien Potencier [Mon, 15 Oct 2012 07:38:17 +0000]
bumped version to 1.10.2-DEV

11 years agoprepared the 1.10.1 release
Fabien Potencier [Mon, 15 Oct 2012 07:35:01 +0000]
prepared the 1.10.1 release

11 years agoupdated macro documentation to warn about a hack that won't work anymore in Twig 2.x
Fabien Potencier [Mon, 15 Oct 2012 07:15:27 +0000]
updated macro documentation to warn about a hack that won't work anymore in Twig 2.x

11 years agomerged branch Adel-E/update-api-docs (PR #858)
Fabien Potencier [Sat, 13 Oct 2012 19:01:24 +0000]
merged branch Adel-E/update-api-docs (PR #858)

This PR was merged into the master branch.

Commits
-------

bee4cd1 Update doc to correspond to the following: http://twig.sensiolabs.org/documentation http://twig.sensiolabs.org/doc/filters/escape.html

Discussion
----------

Update api docs

Update doc to correspond to the following:
http://twig.sensiolabs.org/documentation
http://twig.sensiolabs.org/doc/filters/escape.html

11 years agoUpdate doc to correspond to the following:
eadel [Wed, 10 Oct 2012 23:22:09 +0000]
Update doc to correspond to the following:
http://twig.sensiolabs.org/documentation
http://twig.sensiolabs.org/doc/filters/escape.html

11 years agofixed tests where macros were not used properly
Fabien Potencier [Fri, 12 Oct 2012 14:42:58 +0000]
fixed tests where macros were not used properly

11 years agorefactored previous commit to avoid collission between symbols of different types
Fabien Potencier [Fri, 12 Oct 2012 14:47:13 +0000]
refactored previous commit to avoid collission between symbols of different types

11 years agooptimized macros when imported via the "import" tag
Fabien Potencier [Fri, 12 Oct 2012 13:21:26 +0000]
optimized macros when imported via the "import" tag

This commit unifies the way macros are called independently of how they
were included (via the from or import tag -- see e81c932).

11 years agomerged branch pierrejoye/master (PR #855)
Fabien Potencier [Mon, 8 Oct 2012 13:20:00 +0000]
merged branch pierrejoye/master (PR #855)

This PR was merged into the master branch.

Commits
-------

d398e55 - drop tsrm fetch, not necessary as it is passed as argument already

Discussion
----------

drop unnecessary tsrmls_fetch

11 years ago- drop tsrm fetch, not necessary as it is passed as argument already
Pierre Joye [Mon, 8 Oct 2012 13:15:38 +0000]
- drop tsrm fetch, not necessary as it is passed as argument already

11 years agorefactored some unit tests
Fabien Potencier [Sat, 6 Oct 2012 07:21:32 +0000]
refactored some unit tests

11 years agoupdated CHANGELOG
Fabien Potencier [Fri, 5 Oct 2012 15:09:05 +0000]
updated CHANGELOG

11 years agofixed unit tests when XDebug is enabled
Fabien Potencier [Fri, 5 Oct 2012 15:04:55 +0000]
fixed unit tests when XDebug is enabled

11 years agomerged branch weltling/master (PR #854)
Fabien Potencier [Thu, 4 Oct 2012 17:41:45 +0000]
merged branch weltling/master (PR #854)

This PR was merged into the master branch.

Commits
-------

b013ede fix windows build

Discussion
----------

Trivial fix for windows build

11 years agofix windows build
Anatoliy Belsky [Thu, 4 Oct 2012 16:50:52 +0000]
fix windows build

11 years agomerged branch greg0ire/patch-1 (PR #851)
Fabien Potencier [Sat, 29 Sep 2012 16:33:35 +0000]
merged branch greg0ire/patch-1 (PR #851)

This PR was merged into the master branch.

Commits
-------

d52e15b remove tautology

Discussion
----------

remove tautology

We already know the example is "for example".

11 years agofixed blanks in the doc
Fabien Potencier [Sat, 29 Sep 2012 16:04:58 +0000]
fixed blanks in the doc

11 years agoremove tautology
Grégoire Paris [Sat, 29 Sep 2012 16:02:16 +0000]
remove tautology

11 years agofixed a doc anchor
Fabien Potencier [Sat, 29 Sep 2012 16:01:41 +0000]
fixed a doc anchor

11 years agoupdated CHANGELOG
Fabien Potencier [Fri, 28 Sep 2012 21:55:47 +0000]
updated CHANGELOG

11 years agofixed CS
Fabien Potencier [Fri, 28 Sep 2012 21:50:11 +0000]
fixed CS

11 years agomerged branch char101/master (PR #844)
Fabien Potencier [Fri, 28 Sep 2012 21:45:13 +0000]
merged branch char101/master (PR #844)

This PR was merged into the master branch.

Commits
-------

c23ef25 Add assertEquals to NativeExtensionTest.php
9126dc6 Twig extension: fix case when accessing property of an array casted into object
34cf8e1 Fix double free
4980903 Enhancements for twig extension
db3cb80 Fix NativeExtensionTest
3485ee7 Native extension: handle dynamic properties defined in the get_properties handler in a per instance fashion.

Discussion
----------

Native extension: call get_properties in per instance manner instead of caching it.

Since dynamic properties of an object can be defined by its get_properties handler, we need to call it for each instance.

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

by char101 at 2012-09-21T10:30:37Z

PHPUnit test result

```
PHPUnit 3.7.1 by Sebastian Bergmann.

.S...........................................................   61 / 1253 (  4%)
.............................................................  122 / 1253 (  9%)
.............................................................  183 / 1253 ( 14%)
.............................................................  244 / 1253 ( 19%)
.............................................................  305 / 1253 ( 24%)
.............................................................  366 / 1253 ( 29%)
.............................................................  427 / 1253 ( 34%)
.............................................................  488 / 1253 ( 38%)
.............................................................  549 / 1253 ( 43%)
.............................................................  610 / 1253 ( 48%)
.............................................................  671 / 1253 ( 53%)
.............................................................  732 / 1253 ( 58%)
.............................................................  793 / 1253 ( 63%)
.............................................................  854 / 1253 ( 68%)
.............................................................  915 / 1253 ( 73%)
.............................................................  976 / 1253 ( 77%)
............................................................. 1037 / 1253 ( 82%)
............................................................. 1098 / 1253 ( 87%)
............................................................. 1159 / 1253 ( 92%)
............................................................. 1220 / 1253 ( 97%)
.................................

Time: 4 seconds, Memory: 13.25Mb

OK, but incomplete or skipped tests!
Tests: 1253, Assertions: 2969, Skipped: 1.
```

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

by stof at 2012-09-21T11:58:51Z

@char101 My previous comment about the way the test should be implemented is still valid. Please rewrite it to use the same way to all other integration tests in Twig

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

by char101 at 2012-09-23T04:51:36Z

@stof I don't see the reason of using a fixture. The test case works, it accomplishes its goal. It's simple. It doesn't test for a feature, it tests for a specific case where PHP crashes.

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

by stof at 2012-09-23T13:53:41Z

@char101 I see one: you are building a Twig instance and rendering a template here, which is exactely what the integration tests are doing.
Btw, your test would fail when running phpunit in strict mode as it does not assert anything

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

by char101 at 2012-09-24T02:05:58Z

@stof I don't have the desire to change what isn't broken, but you are free to change it as you see fit. As for the assert, I have added it to the test.

11 years agobumped version to 1.10.1-DEV
Fabien Potencier [Fri, 28 Sep 2012 20:16:13 +0000]
bumped version to 1.10.1-DEV

11 years agoprepared the 1.10.0 release
Fabien Potencier [Fri, 28 Sep 2012 20:11:39 +0000]
prepared the 1.10.0 release

11 years agomerged branch hason/php52 (PR #849)
Fabien Potencier [Wed, 26 Sep 2012 13:56:31 +0000]
merged branch hason/php52 (PR #849)

Commits
-------

adb5d4f Fixed PHP 5.2 incompatibilty

Discussion
----------

Fixed PHP 5.2 incompatibilty

11 years agoFixed PHP 5.2 incompatibilty
Martin Hasoň [Wed, 26 Sep 2012 13:12:41 +0000]
Fixed PHP 5.2 incompatibilty

11 years agoAdd assertEquals to NativeExtensionTest.php
Charles [Mon, 24 Sep 2012 02:04:21 +0000]
Add assertEquals to NativeExtensionTest.php

12 years agoAvoid setting timezones on DateIntervals
Jeremy Mikola [Thu, 20 Sep 2012 11:37:48 +0000]
Avoid setting timezones on DateIntervals

12 years agoTwig extension: fix case when accessing property of an array casted into object
Charles [Fri, 21 Sep 2012 10:29:41 +0000]
Twig extension: fix case when accessing property of an array casted into object

12 years agoFix double free
Charles [Fri, 21 Sep 2012 09:42:13 +0000]
Fix double free

12 years agoEnhancements for twig extension
Charles [Fri, 21 Sep 2012 07:47:45 +0000]
Enhancements for twig extension

- Fix extension memory leak
- Fix gcc compile warning (cast to const char *)
- Add TWIG_HAS_DYNAMIC_PROPERTY
- Remove the previous translation of 'array_key_exists($item, $object)'
  into TWIG_ARRAY_KEY_EXISTS when checking object property because what
  it really means is property_exists which has already been handled by
  TWIG_HAS_PROPERTY and TWIG_HAS_DYNAMIC_PROPERTY
- Fix native extension spacing

12 years agoFix NativeExtensionTest
Charles [Thu, 20 Sep 2012 11:35:44 +0000]
Fix NativeExtensionTest

12 years agoNative extension: handle dynamic properties defined in the get_properties handler...
Charles [Thu, 20 Sep 2012 11:29:21 +0000]
Native extension: handle dynamic properties defined in the get_properties handler in a per instance fashion.

12 years agoupdated CHANGELOG
Fabien Potencier [Tue, 18 Sep 2012 09:38:15 +0000]
updated CHANGELOG

12 years agotweaked docs
Fabien Potencier [Tue, 18 Sep 2012 09:37:33 +0000]
tweaked docs

12 years agomerged branch drak/reusable_fixtures (PR #805)
Fabien Potencier [Tue, 18 Sep 2012 09:34:35 +0000]
merged branch drak/reusable_fixtures (PR #805)

Commits
-------

36372c6 Made node tests reusable

Discussion
----------

Reusable tests and fixtures

This PR makes Twig integration testing reusable for 3rd party extensions.

I have implemented resuable functional tests.

The [test runner](https://github.com/zikula/core/blob/master/src/Zikula/Bundle/CoreBundle/Tests/Twig/IntegrationTest.php) and the [fixtures](https://github.com/zikula/core/tree/master/src/Zikula/Bundle/CoreBundle/Tests/Twig/Fixtures) are the only part that an extension needs to implement itself.

I've included documentation in the PR.

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

by jusuff at 2012-08-11T20:41:55Z

This PR would make things little easier. Right now tests are organized in confusing way and are hard to implement for Twig extensions

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

by drak at 2012-08-14T09:09:45Z

@fabpot - This is ready for merging now. When it's merged I'll update the documentation as this PR significantly eases our ability to test extensions.

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

by fabpot at 2012-09-16T14:28:16Z

@drak Do you plan to update this PR with the code you have in Zikula?

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

by drak at 2012-09-16T14:37:30Z

@fabpot - Yes, I just need a couple of days (or less).

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

by drak at 2012-09-17T12:00:34Z

@fabpot - I have ported over the code.

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

by drak at 2012-09-18T08:23:18Z

@fabpot - I updated Zikula to us this particular branch so there is a practical test. I've updated the links in the top description part of this PR with the relevant links. The PR also refactors Twig's core tests to use the re-usable test base classes.

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

by fabpot at 2012-09-18T09:01:10Z

@drak Can you squash your commits before I merge? Thanks.

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

by drak at 2012-09-18T09:14:08Z

@fabpot - I've squashed them now. Thanks!

12 years agoMade node tests reusable
Drak [Mon, 17 Sep 2012 11:33:27 +0000]
Made node tests reusable

12 years agomerged branch hason/loader (PR #838)
Fabien Potencier [Tue, 18 Sep 2012 05:04:46 +0000]
merged branch hason/loader (PR #838)

Commits
-------

c503287 Fixed typo in Filesystem loader

Discussion
----------

Fixed typo in Filesystem loader

12 years agoFixed typo in Filesystem loader
Martin Hasoň [Mon, 17 Sep 2012 12:11:40 +0000]
Fixed typo in Filesystem loader

12 years agoadded missing information in the doc
Fabien Potencier [Sun, 16 Sep 2012 14:38:44 +0000]
added missing information in the doc

12 years agomerged branch fabpot/named-paths (PR #772)
Fabien Potencier [Sun, 16 Sep 2012 14:34:28 +0000]
merged branch fabpot/named-paths (PR #772)

Commits
-------

7e5acd1 fixed some possible warnings
f0d0d6d fixed typo
b7076fe added Twig_Loader_Filesystem::getNamespaces()
8f7ccd1 moved an exception
9426072 tweaked documentation
b9afa84 renamed the default filesystem namespace to __main__
c34541d changed notation of namespaced templates to @namespace/template_path
0eb4d01 added namespaced templates support in Twig_Loader_Filesystem
c24ea1b added Twig_Loader_Filesystem::prependPath()

Discussion
----------

added namespaced templates support in Twig_Loader_Filesystem

Everything is explained in the updated documentation.

Basically, it gives more flexibility when it comes to manage many templates that are not necessarily related (think frontent vs backend for instance, or templates from different Symfony bundles, ...). It is useful if, for each namespace, you need to look for templates in different directories. This implementation would probably be enough to replace the current Symfony bundle template paths, with more flexibility and less restrictions.

Feedback is more than welcome. One thing I'm not sure about is the `#` separator between the namespace and the template path. Is it the best choice? We need a character that is not used in filesystem paths, so good candidates are: `@`, `!`, `%`, `$`, `*`, `;`, `?`.

Some immediate benefits: give the same template flexibility that we have in Symfony to other frameworks using Twig like Silex. Another benefit would be the ability to share template between Symfony and other frameworks like Twig (more on a proof of concept later).

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

by alessandro1997 at 2012-07-14T16:25:42Z

This is very nice, and I think # is a great choice for the separator character. We could also use @.

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

by jjbohn at 2012-07-14T16:25:59Z

:+1: for #

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

by Symfomany at 2012-07-14T16:27:45Z

Pipe character isn't candidate?

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

by inspiran at 2012-07-14T16:32:52Z

I remember from the wetter.com talk at sf live that they actually implemented a similar functionality: allow twig templates to be defined different from the default path.   So they had something like:

{% extends "cms://Home/weather/..."  ... %}
If we could make the "cms" part a configurable setting then one could use it to point to a custom folder or even to a content provider (symfony cmf?)

Maybe that would be another approach?

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

by fabpot at 2012-07-14T16:33:21Z

The other syntax possibility is something more like we have in Symfony: `@namespace/template_path`.

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

by fabpot at 2012-07-14T16:34:37Z

@inspiran: that's another possibility: use the PHP stream notation.

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

by mvrhov at 2012-07-14T16:36:18Z

I'd also prefer uri/php streams syntax...

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

by Tobion at 2012-07-14T16:41:16Z

On Windows I can create a file with `#` in it. How does it distinguish that? I don't think we will find a single seperation character that works on all file systems, do we? And `@` (e.g. namespace@file) would be semantically strange (unless you read it from right-to-left).
So I'd also prefer uri/php stream syntax.

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

by Symfomany at 2012-07-14T16:43:17Z

@fabpot  Pointer Syntax? or greater than character?

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

by markstory at 2012-07-14T16:43:48Z

I'm in favour of the `foo://` style syntax.  It is similar to other parts of PHP, and avoids overlap with filesystem characters, and doesn't introduce new unique syntax.

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

by stof at 2012-07-14T16:44:25Z

@fabpot ``@namespace/template_path`` would make it confusing in Symfony. Because locating a resource with the kernel would use ``@AcmeDemoBundle/Resources/views/layout.html.twig`` whereas Twig would find the same file as ```@AcmeDemoBundle/layout.html.twig``.

And none of ``#``, ``@``, ``!``, ``%``, ``$`` or ``;`` is forbidden in filenames on Windows.

So I think the URI/stream notation is fine

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

by maryo at 2012-07-14T16:46:44Z

On Windows @!%$; are valid. Invalid characters are \/:*?"<>|

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

by maryo at 2012-07-14T16:47:55Z

Is > allowed on Linux?

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

by jschreuder at 2012-07-14T16:49:17Z

Some thoughts from a non-Symfony user:

* Not sure about the `#`, on the one hand it is used as the comment character on the other hand I'm also familiar with it as a membership operator (which supports its usage)
* The streams/PHP syntax: I don't really like this, the syntax signifies some type of protocol to be used. Even stretched to the limits of its definition you wouldn't be able to define different namespaces as different protocols (same protocol, different location).
* `@namespace/file/path` - kind of like this one, the `@` signifies that it is followed by a special symbol (being the namespace name) and other than that a normal path.
* Another option we've used in Fuel is the double colon `::` as in `namespace::file/path` (like the `#` it signifies membership, but doesn't have another significance in Twig)

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

by gunnarlium at 2012-07-14T17:10:15Z

Does it matter what symbols are valid in filenames? Won't the separator just be used for exploding the string into namespace and path, and thus never be used to directly access a file?

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

by alessandro1997 at 2012-07-14T17:15:27Z

As @gunnarlium said, what's the problem with filenames?

```php
$path = 'namespace#new#page.html';
$parts = explode('#', $path, 2);
list($namespace, $filename) = $parts;

// "namespace and "new#page.html"
var_dump($namespace, $filename);
```

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

by stof at 2012-07-14T17:16:19Z

@gunnarlium the issue is that if you use this symbols in the filename of your template without namespace, Twig will consider it as a namespaced template for another file name

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

by stof at 2012-07-14T17:16:45Z

@alessandro1997 the issue is that namespaces are optional

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

by alessandro1997 at 2012-07-14T17:17:07Z

@stof Oh, right. I didn't get that :-)

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

by gunnarlium at 2012-07-14T17:20:32Z

@stof Ok, I see. So what we want is a symbol which is not allowed as a filename? Or (suboptimally) just add a requirement that template filenames can't contain certain reserved symbols?

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

by fabpot at 2012-07-14T17:23:37Z

But then, who is using `#` in a filename?

Anyway, I'm going to implement a version based on PHP streams to stick to the PHP way. Using a PHP stream might also allow us to get rid of the array loader.

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

by alessandro1997 at 2012-07-14T17:24:01Z

@gunnarlium But how would we check if the user is using reserved symbols in template names? Twig isn't aware of the available templates' names until the user requests them. And when he/she does it's too late because Twig doesn't know if the separator is used as namespace or if it's part of the filename.

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

by stof at 2012-07-14T17:33:38Z

@fabpot even if no sane guy would probably use ``#`` in a filename, it would mean that Twig assumes that all its userbase is sane :)

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

by lolautruche at 2012-07-14T18:51:53Z

-1 for #
+1 for php stream, though I agree with @jschreuder's arguments against it
+2 for @ syntax like in Symfony. I find it more consistent.

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

by fabpot at 2012-07-14T19:50:31Z

One problem with PHP streams is that it makes using template names quite ugly and verbose:

    {% include 'twig://namespace/index.html' %}

And for non-namespaced templates:

    {% include 'twig:///index.html' %}

for which we can provide a shortcut:

    {% include 'index.html' %}

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

by fabpot at 2012-07-14T19:54:35Z

If we are using `@` like in Symfony, it will be:

    {% include '@namespace/index.html' %}

And for non-namespaced templates:

    {% include 'index.html' %}

And for Symfony users, the notation would be the same as for resources. If we register each bundle path as a namespace, the path would even be exactly the same:

    {% include '@AcmeDemoBundle/Resources/views/layout.html.twig' %}

EDIT: that's not so simple because of the templates stored under `app/`.

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

by mahono at 2012-07-14T19:56:54Z

might not be the best idea, but what about using Backslash as namespace char?

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

by fabpot at 2012-07-14T19:57:50Z

@mahono: I have not dared to propose this alternative ;)

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

by fabpot at 2012-07-14T20:06:17Z

I've just made an additional commit that implements the `@namespace/template_path` notation.

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

by Baachi at 2012-07-14T20:32:41Z

The `@` syntax is the most consistent solution.
But the integration in symfony2 is really hard and a BC break.

The stream syntax is not a good solution.
`twig` might already be already registered as a stream.

I would suggest the `::` syntax.

12 years agofixed some possible warnings
Fabien Potencier [Sun, 16 Sep 2012 14:32:36 +0000]
fixed some possible warnings

12 years agofixed typo
Fabien Potencier [Sun, 16 Sep 2012 13:21:03 +0000]
fixed typo