Commit Graph

1336 Commits

Author SHA1 Message Date
Fabien Potencier 1e9a1ae0be optimized parent template creation when the template does not use dynamic inheritance 2012-03-31 15:21:57 +02:00
Fabien Potencier 6e2fd68e7b merged branch lyrixx/error-guess (PR #675)
Commits
-------

d0ae029 Fixed notice in Twig_Error::guessTemplateLine

Discussion
----------

Fixed notice in Twig_Error::guessTemplateLine

Sometimes, `trace['line']` is not available and makes notice.

You can see tests in https://github.com/lyrixx/Silex-Kitchen-Edition/tree/composer.
2012-03-24 00:23:13 +01:00
Grégoire Pineau d0ae0294c0 Fixed notice in Twig_Error::guessTemplateLine 2012-03-23 23:59:21 +01:00
Fabien Potencier a980023df8 merged branch carbonatethis/Documentation (PR #674)
Commits
-------

bf0cc53 Added code snippet to documentation to describe handling null values with date filter

Discussion
----------

Date filter docs update

Added code snippet to documentation to describe handling null values with date filter
2012-03-22 19:43:11 +01:00
cb bf0cc537e3 Added code snippet to documentation to describe handling null values with date filter 2012-03-22 13:12:09 -05:00
Fabien Potencier ab016bd605 bumped version to 1.6.4-DEV 2012-03-22 18:31:45 +01:00
Fabien Potencier c2a53a2614 prepared the 1.6.3 release v1.6.3 2012-03-22 18:28:15 +01:00
Fabien Potencier a4fa6db03b added documentation for the trim filter 2012-03-22 14:34:27 +01:00
Fabien Potencier 4a0773a8ad fixed usage of Z_ADDREF_P for PHP 5.2 in the C extension 2012-03-22 14:25:00 +01:00
Fabien Potencier 405cbb5be2 merged branch shieldo/patch-1 (PR #670)
Commits
-------

7f0cca0 fixed incorrect docblock

Discussion
----------

fixed incorrect docblock

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

by shieldo at 2012-03-19T18:15:41Z

True, and done.

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

by fabpot at 2012-03-19T18:19:33Z

Can you rebase your PR and squash your commits so that we don't have the merge? Thanks.

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

by shieldo at 2012-03-19T18:43:28Z

Sorry about that.  Done. :)
2012-03-19 19:52:05 +01:00
Fabien Potencier 141d622dc9 simplified code 2012-03-19 19:17:36 +01:00
Douglas Greenshields 7f0cca0f7c fixed incorrect docblock 2012-03-19 18:13:53 +00:00
Fabien Potencier 90931b0a27 fixed compilation of numeric values used in templates when using a locale where the decimal separator is not a dot 2012-03-19 00:08:15 +01:00
Fabien Potencier 96632fb481 simplified tests 2012-03-18 03:33:46 +01:00
Fabien Potencier 49ee8d6e41 made the strategy used to guess the real template file name and line number in exception messages much faster and more accurate (refs #647) 2012-03-18 03:33:46 +01:00
Fabien Potencier 2ecd314dc1 bumped version to 1.7.0-DEV 2012-03-18 03:33:04 +01:00
Fabien Potencier f43cc520d6 prepared the 1.6.2 release v1.6.2 2012-03-18 03:23:00 +01:00
Fabien Potencier 50e73b20cb fixed sandbox mode when used with inheritance (closes #656)
The checkSecurity() method must be called by each template as we are not
using inheritance.
2012-03-17 17:11:40 +01:00
Fabien Potencier c0a9c8bb3e added preserveKeys support for the slice filter (closes #669) 2012-03-17 12:42:13 +01:00
Fabien Potencier a3310e75a1 fixed the date filter when a DateTime instance is passed with a specific timezone (closes #660) 2012-03-15 17:24:51 +01:00
Fabien Potencier f1186c3832 merged branch stof/trim_filter (PR #662)
Commits
-------

d942d11 Added a trim filter

Discussion
----------

Added a trim filter

This adds a trim filter in Twig as most people thought it deserves being in the core rather than in the extensions.

Closes #634

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

by fabpot at 2012-03-13T16:47:15Z

I would have added a second option to control whether you trim on both side, only on the left, or only the right. What do you think?

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

by nikic at 2012-03-13T17:15:43Z

@fabpot In that case I'd rather add two additional functions `trim_left` (mapping to `ltrim`) and `trim_right` (mapping to `rtrim`). Should be more obvious than some flag at the end :)

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

by stof at 2012-03-13T18:47:38Z

I tend to think that separate filters would indeed be more obvious. What do you prefer @fabpot ?

And for the flag, how would you specify the option to use ? Using a string ? Using boolean flags is not appropriate here (as we have 3 meaningful cases) and I don't really like the string solution.

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

by fabpot at 2012-03-13T18:53:08Z

I don't like the idea of having 3 different filter just for trimming. That seems overkill to me.

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

by stof at 2012-03-13T19:14:12Z

which API do you suggest for the filter then ?

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

by fabpot at 2012-03-13T19:23:51Z

I've no definitive idea. So, perhaps we can just merge what you've done for now.

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

by Koc at 2012-03-13T20:17:17Z

+1 for merge this. There are different filters for different trimming.

I cannot remember but there are some situations when we got string with whitespaces in variable and `{{- my_variable -}}` couldn't help and we cann't use `spaceless` filter because `my_vaiable` contains not html for example.

upd: oh, sorry, I haven't noticed comment from @nikic .

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

by Tobion at 2012-03-13T21:05:09Z

I suggest `function trim($left = true, $right = true)` but `left` and `right` could also be strings.
That would cover all cases.

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

by raulfraile at 2012-03-13T23:43:28Z

I think 3 different filters would be much clearer than using string/boolean parameters. IMO is the same case than strtolower/strtoupper.
2012-03-15 07:25:00 +01:00
Fabien Potencier f034073fed merged branch raulfraile/patch-1 (PR #665)
Commits
-------

0519419 Updated 'convert_encoding' filter documentation

Discussion
----------

Updated 'convert_encoding' filter documentation

Updated 'convert_encoding' filter documentation to clarify which extension will be used in case both `iconv` and `mbstring` are installed.
2012-03-13 17:44:20 +01:00
Raul Fraile 0519419bfd Updated 'convert_encoding' filter documentation 2012-03-13 17:33:49 +01:00
Christophe Coevoet d942d11f2f Added a trim filter
Closes #634
2012-03-12 14:56:44 +01:00
Fabien Potencier c5ef990807 merged branch andrerom/patch-1 (PR #658)
Commits
-------

be07174 Added @return doc on Twig_LoaderInterface->isFresh()
8315992 Added missing @throws in Twig_LoaderInterface

Discussion
----------

Added missing @throws in Twig_LoaderInterface

Based on Twig_Loader_Chain implementation, this seems to be the possible exception that can be thrown by loaders.
2012-03-10 19:52:41 +01:00
andrerom be0717431c Added @return doc on Twig_LoaderInterface->isFresh() 2012-03-10 16:58:52 +01:00
andrerom 8315992979 Added missing @throws in Twig_LoaderInterface
Based on Twig_Loader_Chain implementation, this seems to be the possible exceptions that can be thrown by loaders.
2012-03-10 16:39:02 +01:00
Fabien Potencier 9f322ab2fd fixed typo 2012-03-01 15:11:11 +01:00
Fabien Potencier e765183c62 fixed previous commit 2012-02-29 22:20:34 +01:00
Fabien Potencier a64a98431f merged branch robo47/docs-install-via-composer (PR #648)
Commits
-------

7153ff6 Installing twig via composer

Discussion
----------

Installing twig via composer

Installing twig via composer
2012-02-29 22:18:38 +01:00
Fabien Potencier c18a0e60fe bumped Twig version 2012-02-29 22:10:49 +01:00
Fabien Potencier 75b954c183 fixed typo in the doc 2012-02-29 22:02:48 +01:00
Fabien Potencier e9cfd2ec85 fixed typos in the doc 2012-02-29 22:00:20 +01:00
Fabien Potencier 30929fde86 prepared the 1.6.1 release v1.6.1 2012-02-29 21:46:35 +01:00
Fabien Potencier 741b11c618 fixed Twig C extension 2012-02-28 23:19:54 +01:00
Fabien Potencier 8274e84d4e fixed CS 2012-02-28 23:19:54 +01:00
Fabien Potencier 9573f2213c added some unit tests 2012-02-28 23:19:50 +01:00
Benjamin Steininger 7153ff6c32 Installing twig via composer 2012-02-27 11:10:31 +01:00
Fabien Potencier 01f733f4b5 added some more information on the spaceless tag documentation 2012-02-21 11:44:24 +01:00
Fabien Potencier 2fb20cdf77 added some information about Twig_Template::getContext() and made it final 2012-02-19 11:09:47 +01:00
Fabien Potencier 229239a0b0 Revert "merged branch m0ppers/master (PR #611)"
This reverts commit 5f4e6d7a0e, reversing
changes made to a61d42084c.
2012-02-19 11:03:22 +01:00
Fabien Potencier 5e11c672de updated CHANGELOG 2012-02-18 10:35:52 +01:00
Fabien Potencier 5f4e6d7a0e merged branch m0ppers/master (PR #611)
Commits
-------

71449e8 Remove optimization (covered by Optimization VAR_ACCESS anyway)

Discussion
----------

Remove optimization (covered by Optimization VAR_ACCESS anyway)

I have an own template class implementing getContext() and this one drove me completely mad after a twig upgrade.

After compilation the resulting templates have:

isset($context['bla'])

vs.

$this->getContext('bla')

Changing the Name Node however didn't have any effect and i saw that due to the optimizations by the SetTemp class twig doesn't even reach the Name Node. In fact SetTemp has the isset optimization hardcoded (which is ok).

I could simply fix my issue by setting optimizations to -9 (all optimizations except VAR_ACCESS). However the issue will reappear immediately when using PHP 5.4. Please remove the isset stuff from the non optimized node and let the optimization handler handle it (which i would disable in my case)

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

by m0ppers at 2012-01-24T17:42:07Z

some hackish script to test what i mean

<?php
require 'lib/Twig/Autoloader.php';
Twig_Autoloader::register();

abstract class Harxtemplate extends Twig_Template
{
    public function getContext($context, $item, $ignoreStrictCheck = false)
    {
        if ($item == "hans") {
            return "hund";
        } else {
            return parent::getContext($context, $item, $ignorStrictCheck);
        }
    }
}

$template = <<<EOT
Der {{ hans }} hat hund
{% if hans %}
hund
{% endif %}
EOT;

$loader = new Twig_Loader_String();
$options = array('base_template_class' => 'Harxtemplate',
//                 'strict_variables' => true, // doesn't work
                 'debug' => true,
                 'optimizations' => -1, // 0 => works
                );
$twig = new Twig_Environment($loader, $options);

echo $twig->render($template);
2012-02-18 10:18:43 +01:00
Fabien Potencier a61d42084c clarified documentation (closes #602) 2012-02-18 10:05:10 +01:00
Fabien Potencier 9e590e910d merged branch mvrhov/patch-1 (PR #603)
Commits
-------

95f8af7 cast $name to a string as $name can in fact be an object implementing __toString function as true in my case.

Discussion
----------

cast $name to a string ...

... because $name can be an object implementing __toString. I have Enum type implementation which implements __toString. Without the cast I'm getting the following exception:
"An exception has been thrown during the rendering of a template ("Warning: Illegal offset type in isset or empty in... "

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

by fabpot at 2012-01-18T08:43:23Z

From where do you call these methods? from your code? from a template?

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

by mvrhov at 2012-01-18T11:17:55Z

I put the enum object as variable into the template and then based on the enum value I display a block.
2012-02-18 10:00:52 +01:00
Fabien Potencier 07385f6a2c updated CHANGELOG 2012-02-18 09:55:38 +01:00
Fabien Potencier c75d5952e3 merged branch Seldaek/markup (PR #638)
Commits
-------

e4590d0 Avoid creating unnecessary Twig_Markup instances, allows testing for falsiness of empty output

Discussion
----------

Avoid creating unnecessary Twig_Markup instances

This allows testing for falsiness of an empty output:

```jinja
{% set foo %}{% block lala %}{% endblock %}{% endset %}

{% if foo %}
   some output with {{ foo }}
{% endif %}
```

Currently this requires `{% if foo|length %}` since the set tag will always return a Twig_Markup.
2012-02-18 09:54:30 +01:00
Jordi Boggiano e4590d0cd8 Avoid creating unnecessary Twig_Markup instances, allows testing for falsiness of empty output 2012-02-17 15:56:34 +01:00
Fabien Potencier 4b1a8e2798 added phpdoc (closes #627) 2012-02-17 14:16:13 +01:00
Fabien Potencier 4dee4e5841 updated the CHANGELOG and documentation for previous merge 2012-02-15 17:29:31 +01:00