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

TemplateController: extra arguments passed to the template are not managed by Symfony #12897

Closed
Rebolon opened this issue Jan 7, 2020 · 4 comments

Comments

@Rebolon
Copy link

Rebolon commented Jan 7, 2020

Playing with TemplateController, i saw in the documentation https://symfony.com/doc/master/templates.html#rendering-a-template-directly-from-a-route that i may send extra arguments

In fact, those extra arguments seems not managed by the TemplateController following the source code https://github.com/symfony/symfony/blob/5.0/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php (same for 4.*)

Maybe the documentation is not enough explicit about what those extra arguments are used byt Symfony, if they are.

@yceruto
Copy link
Member

yceruto commented Jan 7, 2020

You're right, this part is not currently supported:

# optionally you can define some arguments passed to the template
site_name: 'ACME'
theme: 'dark'

but it looks like a good feature to me :)

@Rebolon
Copy link
Author

Rebolon commented Jan 8, 2020 via email

fabpot added a commit to symfony/symfony that referenced this issue Jan 10, 2020
…ra arguments to be sent to the template (Benjamin RICHARD)

This PR was squashed before being merged into the 5.1-dev branch (closes #35257).

Discussion
----------

[FrameworkBundle] TemplateController should accept extra arguments to be sent to the template

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | Fix #... <!-- prefix each issue number with "Fix #", if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->
<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.

Additionally (see https://symfony.com/roadmap):
 - Always add tests and ensure they pass.
 - Never break backward compatibility (see https://symfony.com/bc).
 - Bug fixes must be submitted against the lowest maintained branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too.)
 - Features and deprecations must be submitted against branch master.
-->

In the official documentation (symfony.com/doc/master/templates.html#rendering-a-template-directly-from-a-route) it says that TemplateController should accept extra arguments. In fact it's not available for instance.
So i added the context argument as an array. Because of deprecation of templating, only the twig instance will apply the context argument.

It will need to be implemented in branch 5.

The following issue has been created in documentation project : symfony/symfony-docs#12897

Commits
-------

e27b417 [FrameworkBundle] TemplateController should accept extra arguments to be sent to the template
symfony-splitter pushed a commit to symfony/framework-bundle that referenced this issue Jan 10, 2020
…ra arguments to be sent to the template (Benjamin RICHARD)

This PR was squashed before being merged into the 5.1-dev branch (closes #35257).

Discussion
----------

[FrameworkBundle] TemplateController should accept extra arguments to be sent to the template

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | Fix #... <!-- prefix each issue number with "Fix #", if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->
<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.

Additionally (see https://symfony.com/roadmap):
 - Always add tests and ensure they pass.
 - Never break backward compatibility (see https://symfony.com/bc).
 - Bug fixes must be submitted against the lowest maintained branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too.)
 - Features and deprecations must be submitted against branch master.
-->

In the official documentation (symfony.com/doc/master/templates.html#rendering-a-template-directly-from-a-route) it says that TemplateController should accept extra arguments. In fact it's not available for instance.
So i added the context argument as an array. Because of deprecation of templating, only the twig instance will apply the context argument.

It will need to be implemented in branch 5.

The following issue has been created in documentation project : symfony/symfony-docs#12897

Commits
-------

e27b417817 [FrameworkBundle] TemplateController should accept extra arguments to be sent to the template
@Rebolon
Copy link
Author

Rebolon commented Jan 10, 2020

Will be fixed in next symfony release

@Rebolon Rebolon closed this as completed Jan 10, 2020
@yceruto
Copy link
Member

yceruto commented Jan 10, 2020

See #12929

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants