Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Commits on Nov 7, 2012
  1. prepared the 1.11.0 release

    authored
  2. merged branch char101/fix-build-warning (PR #886)

    authored
    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
  3. Fix build warning for const pointer

    Charles authored
Commits on Nov 6, 2012
  1. merged branch char101/nativeext-exception-info (PR #885)

    authored
    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.
  2. Merge branch 'nativeext-exception-info' of https://github.com/fabpot/…

    Charles authored
    …Twig into nativeext-exception-info
  3. Call Twig_Error constructor

    Charles authored
  4. Handle NULL filename

    Charles authored
  5. Add template name to error message

    Charles authored
Commits on Nov 5, 2012
Commits on Nov 3, 2012
  1. fixed CS

    authored
  2. merged branch fabpot/timezones (PR #876)

    authored
    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.
  3. changed the date filter behavior to always apply the default timezone…

    authored
    …, except if false is passed as the timezone
Commits on Oct 30, 2012
  1. added a paragraph in the docs about how the Twig blocks work (based o…

    authored
    …n an explanation from nikic, closes #704, refs #351)
  2. fixed a stupid test

    authored
  3. fixed broken test

    authored
  4. merged branch fabpot/template_from_string (PR #874)

    authored
    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 symfony-cmf/ContentBundle#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](twigphp/Twig-extensions#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!
  5. merged branch jmikola/patch-1 (PR #845)

    authored
    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?
  6. merged branch vitman/patch-1 (PR #871)

    authored
    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.
  7. @vitman

    Update lib/Twig/Extension/Core.php

    vitman authored committed
Commits on Oct 29, 2012
Commits on Oct 28, 2012
  1. added two new recipes

    authored
  2. fixed phpdoc

    authored
Commits on Oct 27, 2012
  1. merged branch jeremymarc/master (PR #873)

    authored
    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
Commits on Oct 26, 2012
  1. @jeremymarc
Commits on Oct 20, 2012
  1. merged branch fabpot/faster-exceptions (PR #864)

    authored
    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?).~~
Commits on Oct 19, 2012
  1. optimized the way Twig exceptions are managed

    authored
    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.
Something went wrong with that request. Please try again.