Commit Graph

320 Commits

Author SHA1 Message Date
Fabien Potencier da9d2eb834 merged branch Seldaek/isarray (PR #700)
Commits
-------

c88f8e5 Micro-optimizations
70cca66 Simplify code
d78ed66 Add traversable test
5fd2f98 Add docs
b2e1675 Add is array test

Discussion
----------

is array/traversable tests

It's sometimes necessary to display arbitrary data to be able to know if we should recurse or not.

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

by stof at 2012-04-13T12:13:11Z

I'm not sure about the need for ``is array``. All Twig functions related to arrays also support traversable objects

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

by Seldaek at 2012-04-13T12:23:32Z

Well, I like to have both for explicitness and also because I would try is array without looking at the docs, and I don't think it's right to make is array return true for traversables.

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

by fabpot at 2012-04-20T09:38:33Z

One of the main goal of Twig is to abstract the "real" type of the variables. We have already discussed the introduction of many tests like these ones and I have always rejected them.

As many people seems to have a need for them (especially for arrays), I would consider adding the `traversable` test. But as @stof said, Twig tries to blur the difference between traversable objects and arrays, so I'm -1 for adding another test for arrays.

`traversable` is probably not the best name for web designers but I don't know what else we can use here.

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

by stof at 2012-04-20T09:41:05Z

In Jinja, there is a built-in test for this using ``iterable``: http://jinja.pocoo.org/docs/templates/#builtin-tests

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

by Seldaek at 2012-04-20T09:41:32Z

Ok. I can live with dropping the array test. Now for the name,  `is forloopable`? I am kind of at a loss as well apart from traversable. I think if it's clearly mentioned in the docs it's ok.

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

by Seldaek at 2012-04-20T09:52:12Z

iterable sounds ok to me, but just as confusing as traversable I guess to the unknowing. A sidenote, if I update the PR, any objection to adding the "undefined" test as well?

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

by fabpot at 2012-04-20T10:01:27Z

Let's use `iterable` as this is what Jinja already uses. Why would you want an `undefined` test as we already have `defined`? (`if foo is not defined` works well enough)

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

by Seldaek at 2012-04-20T11:16:26Z

I just saw jinja had it on that page, and I thought why not add it too? Still not a huge fan of the "not" for negation.

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

by fabpot at 2012-04-20T12:18:17Z

Well, let's first finish the `iterable` test first and let's discuss `undefined` in another PR or issue.

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

by fabpot at 2012-04-20T17:10:28Z

I can finish the PR is you want.

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

by Seldaek at 2012-04-20T17:13:11Z

If you like sure, it's mostly deleting code anyway. I just have to finish some work stuff now..
2012-04-20 20:09:05 +02:00
Fabien Potencier 037f86aa55 added a note in the documentation about what the C exension does 2012-04-18 07:19:25 +02:00
Jordi Boggiano d78ed667ad Add traversable test 2012-04-13 13:05:17 +02:00
Jordi Boggiano 5fd2f98720 Add docs 2012-04-13 12:58:41 +02:00
Fabien Potencier fe3c17f51f added a tip in the doc 2012-04-08 12:58:26 +02:00
Igor Wiedler 11d4c6af6a [doc] Remove backticks in intro doc 2012-04-07 18:38:17 +03:00
mark_story 2a7102d059 Update docs concerning loop.last. 2012-04-07 09:50:44 -04:00
Fabien Potencier fbacbe60ad added some more information about unknown variable/attributes in the doc (closes #685) 2012-04-05 22:53:39 +02:00
Fabien Potencier b19ef8ea16 fixed doc markup 2012-04-03 09:10:53 +02:00
Fabien Potencier 81807ea95b fixed doc markup 2012-04-03 09:08:32 +02:00
Fabien Potencier 53e89ef2eb fixed doc indexes 2012-04-03 09:07:53 +02:00
Fabien Potencier 8656bd2afe added doc for the sandbox tag 2012-04-03 08:38:32 +02:00
Fabien Potencier 7ea15600ee added a note about sandbox policy checks in the doc (refs #677) 2012-04-03 07:32:06 +02: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 a4fa6db03b added documentation for the trim filter 2012-03-22 14:34:27 +01:00
Raul Fraile 0519419bfd Updated 'convert_encoding' filter documentation 2012-03-13 17:33:49 +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 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
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 a61d42084c clarified documentation (closes #602) 2012-02-18 10:05:10 +01:00
Fabien Potencier 4dee4e5841 updated the CHANGELOG and documentation for previous merge 2012-02-15 17:29:31 +01:00
Victor Zamfir 904dfefb0b fixed typo 2012-02-12 21:10:01 +02:00
Fabien Potencier 8256bfa05c added missing entry in the doc 2012-01-31 11:57:59 +01:00
Fabien Potencier cbadac91cd tweaked doc 2012-01-26 13:25:31 +01:00
Tobias Schultze 2561aa212e typo 2012-01-26 12:48:04 +01:00
Tobias Schultze faa90c9268 updated doc for random function 2012-01-26 12:45:18 +01:00
Tobias Schultze 83a30739b4 typo 2012-01-19 11:11:49 +01:00
Fabien Potencier 96596d5c7f fixed typo in doc (closes #604) 2012-01-19 10:31:26 +01:00
Fabien Potencier d9dc813dfd added a slice filter 2012-01-14 08:49:51 +01:00
Fabien Potencier 4578c176e5 added string support for the reverse filter 2012-01-14 08:49:13 +01:00
Fabien Potencier d95db40838 tweaked doc for the merge filter 2012-01-13 13:14:08 +01:00
Fabien Potencier 087df0513e tweaked documentation 2012-01-13 10:18:17 +01:00
Fabien Potencier b019019485 added one more rule in the coding standards (closes #587) 2012-01-09 08:04:17 +01:00
Fabien Potencier e67d976fce added one more rule to the coding standards 2012-01-08 21:24:46 +01:00
Julien Brochet 3c934f40fe Update doc/coding_standards.rst 2012-01-08 20:37:45 +01:00
Fabien Potencier f06ac33b53 fixed markup in doc 2012-01-08 20:24:02 +01:00
Fabien Potencier bdcb176cc8 added coding standards in the docs 2012-01-08 20:19:11 +01:00
Fabien Potencier fa08e76f09 added a recipe for stateful node visitors 2012-01-07 09:53:33 +01:00
Fabien Potencier 764829f55a added a date function to ease date comparison (closes #571) 2012-01-06 20:32:26 +01:00
Victor Berchet 28b9b7ba44 [Twig] Add a note about multiple inheritance (use tag) 2012-01-06 09:22:05 +01:00
Lenar Lõhmus 5214794f97 compiles -> compile 2012-01-04 16:26:15 +02:00
Fabien Potencier aa037c80c4 added a note about the Twig extension DLL for Windows 2012-01-04 15:15:01 +01:00
Fabien Potencier 029ebe93c3 fixed doc (closes #577) 2012-01-03 21:52:27 +01:00
Grégoire Pineau 7e8df56852 Fixed CS 2012-01-03 18:31:08 +01:00
Fabien Potencier f64d976182 updated doc for the date filter 2011-12-30 09:21:01 +01:00
Fabien Potencier 88de457774 tweaked previous merge 2011-12-28 20:34:32 +01:00