web/konrad/twig.git
13 years agoRecipe code formatting fix. New recipe for improved APC bytecode support
Andreas Runfalk [Wed, 22 Jun 2011 09:03:56 +0000]
Recipe code formatting fix. New recipe for improved APC bytecode support

13 years agofixed possible security problems with NUL bytes
Fabien Potencier [Fri, 17 Jun 2011 07:17:45 +0000]
fixed possible security problems with NUL bytes

13 years agoreleasing 1.1.0 RC2
Fabien Potencier [Fri, 17 Jun 2011 05:03:39 +0000]
releasing 1.1.0 RC2

13 years agoadded Twig_Error::getRawMessage()
Fabien Potencier [Thu, 16 Jun 2011 08:04:13 +0000]
added Twig_Error::getRawMessage()

13 years agoadded an exception when the template passed to "use" is not a string
Fabien Potencier [Thu, 16 Jun 2011 07:57:17 +0000]
added an exception when the template passed to "use" is not a string

13 years agomerged branch henrikbjorn/issue-347 (PR #348)
Fabien Potencier [Thu, 16 Jun 2011 07:45:47 +0000]
merged branch henrikbjorn/issue-347 (PR #348)

Commits
-------

a8d29b1 Add testcase for issue #347

Discussion
----------

Add testcase for issue #347

Dismisses false issue.

13 years agoupdated CHANGELOG
Fabien Potencier [Thu, 16 Jun 2011 07:45:16 +0000]
updated CHANGELOG

13 years agomerged branch nikic/nestedDefinedTestWithStrictVars (PR #359)
Fabien Potencier [Thu, 16 Jun 2011 07:41:50 +0000]
merged branch nikic/nestedDefinedTestWithStrictVars (PR #359)

Commits
-------

f2a1c2b Refactor and add additional default filter tests
e760483 Make `a.b is defined` not throw an exception if a is not defined (in strict mode)

Discussion
----------

Make `a.b is defined` not throw an exception if a is not defined (in strict mode)

This commit does two things: Firstly (that's the main part) it makes `a.b is defined` not throw an error in strict mode if `a` is undefined (applies for `a.b.c` aso too) [fixes #337]. Additionally it allows `a.b|default` just like it is allowed to do `a|default`.

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

by fabpot at 2011/06/09 22:21:11 -0700

This is quite a big change. Can you add some tests?

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

by nikic at 2011/06/10 08:19:49 -0700

I added some more tests for the default filter in the fixtures. But I wasn't sure how I should test the default test's behavior in strict mode. If you could point me in the right direction here I would add those tests, too ;)

13 years agoupdated CHANGELOG
Fabien Potencier [Thu, 16 Jun 2011 07:41:31 +0000]
updated CHANGELOG

13 years agomerged branch arnaud-lb/line-numbers (PR #353)
Fabien Potencier [Thu, 16 Jun 2011 07:31:53 +0000]
merged branch arnaud-lb/line-numbers (PR #353)

Commits
-------

5ec1955 added {% line \d+ %} directive

Discussion
----------

added {% line \d+ %} directive

This directive allows to change the current line number in the tokenizer.

This allows to generate Twig code from some other Twig or partially-Twig script, and still get relevant line numbers in error messages, when the line numbers of the generated Twig script do not match those of the original script.

For example in the following script:

    foo
    {% line 10 %}
    bar
    {{ baz }}

`"foo"` is on line 1, `"bar"` is considered to be on line 10 and `{{ baz }}` is considered to be on line 11.

This is similar to `# line ...` directives in C.

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

by nikic at 2011/06/05 08:51:20 -0700

I don't quite yet understand it's use cases.

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

by arnaud-lb at 2011/06/05 09:17:57 -0700

The `{% line ... %}` directive is not meant to be used by humans, but rather by generators.

The use case is the same as [#line directives in C](http://gcc.gnu.org/onlinedocs/cpp/Line-Control.html): when you generate a C file from a template, you would prefer that the compiler refers to the line number of the template, instead of the line number of the generated file.

In my case, I built a [HAML compiler for php](https://github.com/arnaud-lb/MtHaml) which can target Twig as an output language. I use it as a Twig pre-processor so that it translates HAML scripts to Twig scripts on the fly in a custom Twig_Loader.

So I have scripts like that:

    %p
      test
    %div = foo.bar

which is compiled like that:

    <p>
      test
    </p>
    <div>
       {{ foo.bar }}
    </div>

If an error occurs in the execution of {{ foo.bar }}, Twig will throw an error refering to line 5 in the original script, which is wrong. A simple solution to this is the {% line %} directive:

    <p>
      test
    </p>
    <div>
    {% line 3 %}
       {{ foo.bar }}
    </div>

Now if an error occures in {{ foo.bar }}, the error will refer to line 3.

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

by nikic at 2011/06/05 09:33:26 -0700

Ah, okay, seems reasonable. Though I'm not sure whether it is appropriate to use the comment syntax to accomplish that.

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

by arnaud-lb at 2011/06/05 10:41:03 -0700

You are right, I changed the request to use the block syntax instead.

13 years agoadded null as an alias for the none test
Fabien Potencier [Tue, 14 Jun 2011 06:19:32 +0000]
added null as an alias for the none test

13 years agoRefactor and add additional default filter tests
nikic [Fri, 10 Jun 2011 14:50:20 +0000]
Refactor and add additional default filter tests

13 years agoMake `a.b is defined` not throw an exception if a is not defined (in strict mode)
nikic [Thu, 9 Jun 2011 18:50:48 +0000]
Make `a.b is defined` not throw an exception if a is not defined (in strict mode)

13 years agoadded Twig_Loader_Filesystem::addPath()
Fabien Potencier [Tue, 7 Jun 2011 14:33:55 +0000]
added Twig_Loader_Filesystem::addPath()

13 years agoadded {% line \d+ %} directive
Arnaud Le Blanc [Sun, 5 Jun 2011 17:38:12 +0000]
added {% line \d+ %} directive

13 years agoadded missing debug info when using traits
Fabien Potencier [Sun, 5 Jun 2011 10:12:05 +0000]
added missing debug info when using traits

13 years agofixed Twig_Error when the exception is thrown from within the generated template
Fabien Potencier [Sun, 5 Jun 2011 10:07:30 +0000]
fixed Twig_Error when the exception is thrown from within the generated template

13 years agoAdd testcase for issue #347
Henrik Bjørnskov [Wed, 1 Jun 2011 13:27:40 +0000]
Add testcase for issue #347

13 years agoupdated VERSION
Fabien Potencier [Sat, 28 May 2011 15:35:04 +0000]
updated VERSION

13 years agoreleasing 1.1.0 RC1
Fabien Potencier [Sat, 28 May 2011 15:34:18 +0000]
releasing 1.1.0 RC1

13 years agoupdated CHANGELOG
Fabien Potencier [Sat, 28 May 2011 15:01:35 +0000]
updated CHANGELOG

13 years agoMerge remote branch 'tna/default-filter'
Fabien Potencier [Sat, 28 May 2011 14:38:25 +0000]
Merge remote branch 'tna/default-filter'

* tna/default-filter:
  Moved default filter fix to its proper place
  Fixes default filter

13 years agofixed timezone when using the date filter with a UNIX timestamp (it now uses the...
Fabien Potencier [Sat, 28 May 2011 14:36:42 +0000]
fixed timezone when using the date filter with a UNIX timestamp (it now uses the default timezone instead of UTC to mimics the date() function behavior)

13 years agoDate filter should treat strict integers as Unix timestamps (same as all-digit strings)
Jeremy Mikola [Fri, 27 May 2011 18:54:06 +0000]
Date filter should treat strict integers as Unix timestamps (same as all-digit strings)

Without a string cast, ctype_digit() will return false for an integer.

13 years agoMoved default filter fix to its proper place
Tobias Naumann [Thu, 26 May 2011 15:00:59 +0000]
Moved default filter fix to its proper place

13 years agoFixes default filter
Tobias Naumann [Thu, 26 May 2011 09:14:15 +0000]
Fixes default filter

13 years agoRefactor GetAttr defined implementation to consider null defined
nikic [Tue, 24 May 2011 10:48:47 +0000]
Refactor GetAttr defined implementation to consider null defined

13 years agofixed constructor + cosmetic
Brikou CARRE [Fri, 20 May 2011 12:25:21 +0000]
fixed constructor + cosmetic

13 years agotweaked docs
Fabien Potencier [Wed, 18 May 2011 06:14:47 +0000]
tweaked docs

13 years agoAdd some further is defined unit tests and give clearer names
nikic [Tue, 3 May 2011 17:07:35 +0000]
Add some further is defined unit tests and give clearer names

13 years agoFix regression in defined test for GetAttr. Fixes #319
nikic [Tue, 3 May 2011 16:56:57 +0000]
Fix regression in defined test for GetAttr. Fixes #319

13 years agoMerge remote branch 'jpb0104/master'
Fabien Potencier [Wed, 18 May 2011 06:05:56 +0000]
Merge remote branch 'jpb0104/master'

* jpb0104/master:
  Added an example of escaped "at" in a date filter.

13 years agoAdded an example of escaped "at" in a date filter.
Jason Bouffard [Tue, 17 May 2011 21:28:44 +0000]
Added an example of escaped "at" in a date filter.

Relates to https://github.com/fabpot/Twig/issues/330

13 years agosimplified code
Fabien Potencier [Tue, 10 May 2011 05:21:09 +0000]
simplified code

13 years agoadded a test for the raw tag
Fabien Potencier [Mon, 9 May 2011 15:47:21 +0000]
added a test for the raw tag

13 years agomoved a test
Fabien Potencier [Mon, 9 May 2011 15:47:09 +0000]
moved a test

13 years agofixed parsing problem when a large chunk of text is enclosed in a raw tag
Fabien Potencier [Mon, 9 May 2011 15:35:00 +0000]
fixed parsing problem when a large chunk of text is enclosed in a raw tag

This is a quick and ugly fix... This should be refactored later on

13 years agofixed CS
Fabien Potencier [Mon, 9 May 2011 14:31:32 +0000]
fixed CS

13 years agoupdated email address
Fabien Potencier [Fri, 29 Apr 2011 15:18:51 +0000]
updated email address

13 years agoupdated CHANGELOG
Fabien Potencier [Fri, 29 Apr 2011 15:14:17 +0000]
updated CHANGELOG

13 years agomade a small speed optimization when using auto-escaping
Fabien Potencier [Fri, 29 Apr 2011 13:23:00 +0000]
made a small speed optimization when using auto-escaping

13 years agoupdated version
Fabien Potencier [Fri, 29 Apr 2011 10:45:10 +0000]
updated version

13 years agoCompiler.php - CS fix
Joseph Bielawski [Fri, 29 Apr 2011 09:59:03 +0000]
Compiler.php - CS fix

13 years agoTokenParserBroker.php - CS fix
Joseph Bielawski [Fri, 29 Apr 2011 09:57:54 +0000]
TokenParserBroker.php - CS fix

13 years agoParser.php - CS fix
Joseph Bielawski [Fri, 29 Apr 2011 09:56:34 +0000]
Parser.php - CS fix

13 years agoLexer.php - CS fix
Joseph Bielawski [Fri, 29 Apr 2011 09:54:59 +0000]
Lexer.php - CS fix

13 years agoEnvironment.php - CS fix
Joseph Bielawski [Fri, 29 Apr 2011 09:46:23 +0000]
Environment.php - CS fix

13 years agoTokenParserBroker.php - CS fix
Joseph Bielawski [Fri, 29 Apr 2011 09:42:36 +0000]
TokenParserBroker.php - CS fix

13 years agofixed typo in the doc
Fabien Potencier [Fri, 29 Apr 2011 09:38:34 +0000]
fixed typo in the doc

13 years agoDRY optimization
Joseph Bielawski [Fri, 29 Apr 2011 08:34:13 +0000]
DRY optimization

13 years agoupdated CHANGELOG
Fabien Potencier [Fri, 29 Apr 2011 08:18:57 +0000]
updated CHANGELOG

13 years agoadded some tests for the use tag
Fabien Potencier [Fri, 29 Apr 2011 07:42:28 +0000]
added some tests for the use tag

13 years agoadded documentation for traits
Fabien Potencier [Fri, 29 Apr 2011 06:25:03 +0000]
added documentation for traits

13 years agoadded support for block renaming when importing traits
Fabien Potencier [Thu, 28 Apr 2011 21:57:39 +0000]
added support for block renaming when importing traits

    {% use 'TwigBundle:Form:div_layout.html.twig' with text_widget as foo_text_widget %}

13 years agoadded support for traits (experimental)
Fabien Potencier [Wed, 13 Apr 2011 08:23:46 +0000]
added support for traits (experimental)

Traits are "special" templates that define blocks that you can "include" in
other templates.

Let's take an example:

    {# 'foo' template defines the 'foo' block #}
    {% block 'foo' %}
        FOO
    {% endblock %}

    {# 'main' template defines the 'bar' block and include the 'foo' block from the 'foo' template #}
    {% extends 'base' %}

    {% use 'foo' %}

    {% block 'bar' %}
        BAR
    {% endblock %}

In the previous example, the 'main' template use the 'foo' one. It means that
the 'foo' block defined in the 'foo' template is available as if it were
defined in the 'main' template.

You can use as many 'use' statements as you want in a template:

    {% extends 'base' %}

    {% use 'foo' %}
    {% use 'bar' %}
    {% use 'foobar' %}

If two templates define the same block, the latest one wins. The template can
also overrides any block.

The 'use' tag also supports "dynamic" names:

    {% set foo = 'foo' %}

    {% use foo %}

The 'use' tag only imports a template if it does not extend another template,
if it does not define macros, and if the body is empty. But it can 'use' other
templates:

    {# 'foo' template #}
    {% block 'foo' %}
        FOO
    {% endblock %}

    {# 'bar' template #}
    {% use 'foo' %}

    {% block 'bar' %}
        BAR
    {% endblock %}

    {# 'main' template #}
    {% extends 'base' %}

    {% use 'bar' %}

In this example, the 'main' template has access to both 'foo' and 'bar'.

Traits are mainly useful when you consider blocks as reusable "functions";
like we do in Symfony2 forms or if you use Twig for code generation.

13 years agoadded a unit test
Fabien Potencier [Thu, 28 Apr 2011 14:21:27 +0000]
added a unit test

13 years agoMerge remote branch 'nikic/fixIncorrectGetAttrDefinedSoftCheck'
Fabien Potencier [Thu, 28 Apr 2011 14:20:15 +0000]
Merge remote branch 'nikic/fixIncorrectGetAttrDefinedSoftCheck'

* nikic/fixIncorrectGetAttrDefinedSoftCheck:
  Use a type strict null check for GetAttr defined tests. Fixes #305

13 years agoRevert "refactored some tests"
Fabien Potencier [Thu, 28 Apr 2011 11:18:02 +0000]
Revert "refactored some tests"

This reverts commit d45c980a41729e9506148f46c4fd6dc70907b0ad.

Tests should work on PHP 5.2

13 years agoUse a type strict null check for GetAttr defined tests. Fixes #305
nikic [Thu, 28 Apr 2011 11:17:49 +0000]
Use a type strict null check for GetAttr defined tests. Fixes #305

13 years agofixes performance regression
lenar [Thu, 28 Apr 2011 08:27:40 +0000]
fixes performance regression

The regression was introduced by 1e09c7b660856b8178c1.

13 years agoSimplify fix.
Joseph Bielawski [Wed, 27 Apr 2011 15:50:08 +0000]
Simplify fix.

13 years agoAdditional tests for issue #307
Joseph Bielawski [Wed, 27 Apr 2011 15:01:08 +0000]
Additional tests for issue #307

13 years agoFix for issue #307
Joseph Bielawski [Wed, 27 Apr 2011 14:57:39 +0000]
Fix for issue #307

13 years agoadded template file information when an error occurs during compilation
Fabien Potencier [Fri, 22 Apr 2011 14:08:07 +0000]
added template file information when an error occurs during compilation

13 years agotweaked Twig_Error to keep the passed line or template when passed in the constructor...
Fabien Potencier [Fri, 22 Apr 2011 14:06:50 +0000]
tweaked Twig_Error to keep the passed line or template when passed in the constructor and findTemplateInfo() was not able to guess it better

13 years agoadded PhpStorm as IDE that supports Twig out of the box
Fabien Potencier [Fri, 22 Apr 2011 07:53:49 +0000]
added PhpStorm as IDE that supports Twig out of the box

13 years agoadded a unit test
Fabien Potencier [Fri, 15 Apr 2011 14:21:45 +0000]
added a unit test

13 years agofixed typos in the doc
Fabien Potencier [Thu, 14 Apr 2011 08:03:43 +0000]
fixed typos in the doc

13 years agotweaked doc
Fabien Potencier [Thu, 14 Apr 2011 05:42:28 +0000]
tweaked doc

13 years agofixed typo in doc
Fabien Potencier [Thu, 14 Apr 2011 05:39:48 +0000]
fixed typo in doc

13 years agoupdated CHANGELOG
Fabien Potencier [Thu, 14 Apr 2011 05:37:17 +0000]
updated CHANGELOG

13 years agoadded null as an alias to none and made TRUE, FALSE, and NONE equivalent to true...
Fabien Potencier [Thu, 14 Apr 2011 05:35:58 +0000]
added null as an alias to none and made TRUE, FALSE, and NONE equivalent to true, false, and none

13 years agoMerge remote branch 'markstory/whitespace'
Fabien Potencier [Thu, 14 Apr 2011 05:22:57 +0000]
Merge remote branch 'markstory/whitespace'

* markstory/whitespace:
  Updating documentation for whitespace trim tags.
  Making trim tags consume all whitespace, both horizontal and vertical.
  Adding additional test suggested by nikic.
  Making a capturing group non capturing, as the group isn't used.
  Moving newline trimming into the regexp used to match end of tags.
  Applying changes suggested by nikic to simplify how end of comments are processed.
  Fixing some whitespace.
  Fixing typo.
  Adding a bit of documentation for whitespace trimming.
  Adding whitespace trimming support to other tag types (comments, variables) Refactoring how whitespace trimming is done, and moving it into a separate option that is combined with other tag types. Adding more tests. Refs #284
  Fixing use of non-existent method name.
  Adding a test case for mixing {%- and %} tags together.
  Adding a test that uses tabs. Added a test for trailing tabs and -%} Refs #284
  Implementing {%- which trims non-newline whitespace preceding it. Refs

13 years agoUpdating documentation for whitespace trim tags.
Mark Story [Thu, 14 Apr 2011 02:15:32 +0000]
Updating documentation for whitespace trim tags.

13 years agoMaking trim tags consume all whitespace, both horizontal and vertical.
Mark Story [Thu, 14 Apr 2011 02:10:57 +0000]
Making trim tags consume all whitespace, both horizontal and vertical.

13 years agoremoved empty if
Fabien Potencier [Tue, 12 Apr 2011 14:04:26 +0000]
removed empty if

13 years agotweaked error message when wrapping an external exception
Fabien Potencier [Tue, 12 Apr 2011 13:37:51 +0000]
tweaked error message when wrapping an external exception

13 years agomade Twig_Error::findTemplateInfo() more robust
Fabien Potencier [Tue, 12 Apr 2011 12:42:00 +0000]
made Twig_Error::findTemplateInfo() more robust

13 years agorefactored some tests
Fabien Potencier [Tue, 12 Apr 2011 08:21:00 +0000]
refactored some tests

13 years agofixed some tests
Fabien Potencier [Tue, 12 Apr 2011 07:35:37 +0000]
fixed some tests

13 years agotweaked error wrapping
Fabien Potencier [Tue, 12 Apr 2011 07:12:05 +0000]
tweaked error wrapping

13 years agorefactored some tests
Fabien Potencier [Tue, 12 Apr 2011 07:22:15 +0000]
refactored some tests

13 years agoremoved line parameter from Twig_Template::getAttribute() and getContext() as the...
Fabien Potencier [Tue, 12 Apr 2011 06:11:29 +0000]
removed line parameter from Twig_Template::getAttribute() and getContext() as the information is now gathered by Twig_Error_Wrapped

13 years agoadded a Twig_Error_Wrapped exception to try to add template name and line when a...
Fabien Potencier [Tue, 12 Apr 2011 05:58:02 +0000]
added a Twig_Error_Wrapped exception to try to add template name and line when a problem occurs at runtime

13 years agoRevert "deleted abstract method doDisplay (maintain BC)"
Fabien Potencier [Tue, 12 Apr 2011 05:54:05 +0000]
Revert "deleted abstract method doDisplay (maintain BC)"

This reverts commit 70d90bedce7788f5aac35357975aaf6c6a584baf.

13 years agoMerge remote branch 'hason/template'
Fabien Potencier [Tue, 12 Apr 2011 05:53:48 +0000]
Merge remote branch 'hason/template'

* hason/template:
  deleted abstract method doDisplay (maintain BC)
  added possibility to customize "display" in the base template class

13 years agoMerge remote branch 'nikic/fixWrongMethodCallInTest'
Fabien Potencier [Mon, 11 Apr 2011 16:51:49 +0000]
Merge remote branch 'nikic/fixWrongMethodCallInTest'

* nikic/fixWrongMethodCallInTest:
  $e->setFilename to $e->setTemplateFile in integrationTest

13 years ago[doc] added the link to the Twig Netbeans plugin.
Hugo Hamon [Wed, 6 Apr 2011 22:31:51 +0000]
[doc] added the link to the Twig Netbeans plugin.

13 years agoAdding additional test suggested by nikic.
Mark Story [Wed, 6 Apr 2011 01:29:38 +0000]
Adding additional test suggested by nikic.

13 years agoMaking a capturing group non capturing, as the group isn't used.
Mark Story [Wed, 6 Apr 2011 01:06:58 +0000]
Making a capturing group non capturing, as the group isn't used.

13 years agoMoving newline trimming into the regexp used to match end of tags.
Mark Story [Sat, 2 Apr 2011 14:11:44 +0000]
Moving newline trimming into the regexp used to match end of tags.

13 years agoApplying changes suggested by nikic to simplify how end of comments are processed.
Mark Story [Sat, 2 Apr 2011 14:08:51 +0000]
Applying changes suggested by nikic to simplify how end of comments are processed.

13 years agoFixing some whitespace.
Mark Story [Sat, 2 Apr 2011 14:05:55 +0000]
Fixing some whitespace.

13 years agoFixing typo.
Mark Story [Fri, 1 Apr 2011 01:24:00 +0000]
Fixing typo.

13 years agoAdding a bit of documentation for whitespace trimming.
Mark Story [Thu, 31 Mar 2011 01:55:15 +0000]
Adding a bit of documentation for whitespace trimming.

13 years ago$e->setFilename to $e->setTemplateFile in integrationTest
nikic [Wed, 30 Mar 2011 15:37:23 +0000]
$e->setFilename to $e->setTemplateFile in integrationTest

13 years agoAdding whitespace trimming support to other tag types (comments, variables)
Mark Story [Wed, 30 Mar 2011 11:33:04 +0000]
Adding whitespace trimming support to other tag types (comments, variables)
Refactoring how whitespace trimming is done, and moving it into a separate option that is combined with other tag types.
Adding more tests.
Refs #284

13 years agoFixing use of non-existent method name.
Mark Story [Wed, 30 Mar 2011 11:32:06 +0000]
Fixing use of non-existent method name.

13 years agoAdding a test case for mixing {%- and %} tags together.
Mark Story [Wed, 23 Mar 2011 03:08:51 +0000]
Adding a test case for mixing {%- and %} tags together.

13 years agoAdding a test that uses tabs.
Mark Story [Wed, 23 Mar 2011 02:59:56 +0000]
Adding a test that uses tabs.
Added a test for trailing tabs and -%}
Refs #284