Fabien Potencier 6fe2924795 feature #3277 Support object initialisation shortcut {a} == {a:a} from ES2015 (GromNaN)
This PR was submitted for the 3.x branch but it was merged into the 1.x branch instead.

Discussion
----------

Support object initialisation shortcut {a} == {a:a} from ES2015

Object declaration in Twig is very close to the Javascript syntax and is targeting the same profil of developers. In order to provide a smooth developer experience, Twig should implement some new feature of ECMAScript.

Since ECMAScript 2015, a short syntax can be used to declare an object when the key is identical to a defined variable (see [MDN doc](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Object_initializer))

```js
// Shorthand property names (ES2015)
let a = 'foo', b = 42, c = {};
let o = {a, b, c}
```

This PR adds the same syntax to Twig.
This can be very useful for `include ... with ... only` :
```twig
{% set title = "My title" %}
{% set image = "image.jpg" %}
{{ include "template.twig" with {title, image} only }}
# instead of
{{ include "template.twig" with {title: title, image: image} only }}
```

Commits
-------

133edb36 Support object init from variable
2020-08-23 13:55:00 +02:00
2020-08-23 13:54:49 +02:00
2019-11-11 17:50:21 +01:00
2020-06-22 08:11:03 +02:00
2020-08-23 13:54:49 +02:00
2020-08-23 13:54:49 +02:00
2019-10-17 09:29:33 +02:00
2019-08-08 18:07:23 +02:00
2020-05-21 11:01:36 +02:00
2020-08-05 17:06:12 +02:00
2020-05-21 07:36:43 +02:00
2020-06-22 09:21:52 +02:00
2020-02-11 17:31:46 +01:00
2020-08-23 12:46:19 +02:00

Twig, the flexible, fast, and secure template language for PHP
==============================================================

Twig is a template language for PHP, released under the new BSD license (code
and documentation).

Twig uses a syntax similar to the Django and Jinja template languages which
inspired the Twig runtime environment.

Sponsors
--------

.. raw:: html

    <a href="https://blackfire.io/docs/introduction?utm_source=twig&utm_medium=github_readme&utm_campaign=logo">
        <img src="https://static.blackfire.io/assets/intemporals/logo/png/blackfire-io_secondary_horizontal_transparent.png?1" width="255px" alt="Blackfire.io">
    </a>

More Information
----------------

Read the `documentation`_ for more information.

.. _documentation: https://twig.symfony.com/documentation
Languages
PHP 99.9%