Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not respect both include syntaxes #60

Closed
kristiaanvandeneynde opened this issue May 10, 2019 · 3 comments
Closed

Does not respect both include syntaxes #60

kristiaanvandeneynde opened this issue May 10, 2019 · 3 comments

Comments

@kristiaanvandeneynde
Copy link

kristiaanvandeneynde commented May 10, 2019

This is a follow-up to #49


While the twigcs now correctly allows the following code to pass:

{% set foo %}1{% endset %}{{ include("foo.html.twig", {foo: foo}) }}

Valid as per: https://twig.symfony.com/doc/2.x/functions/include.html

It does not support:

{% set foo %}1{% endset %}{% include "foo.html.twig" with {foo: foo} %}

Valid as per: https://twig.symfony.com/doc/2.x/tags/include.html


The latter include tag is more popular in certain projects as the include function is then only called when trying to assign the inclusion result to a variable. When trying to output the include result, the tag syntax is preferred.

So please support both syntaxes as they are both valid.

You can add these lines to FunctionalTest.php:150 to check for the failure:

['{% set foo %}1{% endset %}{% include "foo.html.twig" with {foo: foo} %}', null],
['{% set foo %}1{% endset %}{% include "foo.html.twig" with {foo: foo} only %}', null],
@yguedidi
Copy link
Contributor

I was about to report the same issue, but with:

{% include "foo.html.twig" with {foo: foo} only %}

(using {%, not {{)

@kristiaanvandeneynde
Copy link
Author

kristiaanvandeneynde commented May 24, 2019

My bad, the syntax for the tag method obviously uses {%

@OwlyCode
Copy link
Collaborator

This is on master, and scheduled for next beta version.

@OwlyCode OwlyCode added this to the 4.0.0 milestone Oct 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants