Thanks to visit codestin.com
Credit goes to github.com

Skip to content

The templating-related shortcuts in the base controller should be usable without the Templating component #15502

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

Closed
stof opened this issue Aug 10, 2015 · 15 comments

Comments

@stof
Copy link
Member

stof commented Aug 10, 2015

In Symfony 2.7, we made it possible to use most features of Symfony without enabling the templating component (assuming you don't use a bundle relying on them of course).
However, we have 3 shortcut methods in the base controller which are not compatible with such setup and force the usage of the templating component:

  • render
  • renderView
  • stream

Most projects based on Symfony are probably relying on them, as this is the documented way to render templates.

All of them can be implemented on top of Twig directly quite easily. I suggest doing this in 2.8 in case the templating component is not available.

@fabpot
Copy link
Member

fabpot commented Aug 10, 2015

👍

On 10 août 2015, at 16:06, Christophe Coevoet [email protected] wrote:

In Symfony 2.7, we made it possible to use most features of Symfony without enabling the templating component (assuming you don't use a bundle relying on them of course).
However, we have 3 shortcut methods in the base controller which are not compatible with such setup and force the usage of the templating component:

render
renderView
stream
Most projects based on Symfony are probably relying on them, as this is the documented way to render templates.

All of them can be implemented on top of Twig directly quite easily. I suggest doing this in 2.8 in case the templating component is not available.


Reply to this email directly or view it on GitHub.

@aitboudad
Copy link
Contributor

why not removing the deps in TwigEngine instead ?

@stof
Copy link
Member Author

stof commented Aug 10, 2015

@aitboudad TwigEngine is only about implementing the interface of the Templating component on top of Twig. Removing the deps in it does not make sense, as it is its goal.

@dosten
Copy link
Contributor

dosten commented Aug 10, 2015

IMO the templating component dependency cannot be removed until 3.0 in order to keep BC.

If Twig it's the only enabled engine, we can use it, if not, we should use the templating component.

Also, the template path is different when using Twig or the Templating component, so, doing this automatically can be a BC break.

@stof
Copy link
Member Author

stof commented Aug 11, 2015

@dosten I'm not asking to stop using the templating component when it is available. I'm asking to be able to use the shortcuts when it is not.

and no, the template name is not different. You can have more syntaxes when using Twig directly (but this is also the case when Twig is the only engine enabled), but the bundle:folder:file.format.twig format is supported with Twig too (otherwise you could not use it when referencing a template from Twig itself)

@Koc
Copy link
Contributor

Koc commented Aug 26, 2015

Does anybody know what also missing when we using native twig without Templating component? For example stopwatch.

@wouterj
Copy link
Member

wouterj commented Aug 26, 2015

@Koc I think everything will still be available. Currently, lots of things are duplicated for Templating and Twig

@stof
Copy link
Member Author

stof commented Aug 26, 2015

@Koc Stopwatch integration is indeed not supported there. It might be worth adding it (the native Twig profiler is great to know what happens in Twig itself, but it does not play well with the big picture or the request).

@wouterj I don't understand your comment

@wouterj
Copy link
Member

wouterj commented Aug 26, 2015

@stof sorry, I wrote a bad sentence and wrongly understood @Koc's question (I thought he was talking about the stopwatch extension and not the TimedPhpEngine).

@Koc
Copy link
Contributor

Koc commented Aug 26, 2015

@stof what can you suggest? In what directions should i moving for adding stopwatch? I have only one sollution: override base template class and override render method.

@wouterj
Copy link
Member

wouterj commented Aug 26, 2015

@Koc can't you decorate the Twig_Environment and add the stopwatch functionality?

@Koc
Copy link
Contributor

Koc commented Aug 26, 2015

Koc added a commit to Koc/symfony that referenced this issue Sep 4, 2015
Koc added a commit to Koc/symfony that referenced this issue Sep 4, 2015
fabpot added a commit that referenced this issue Sep 14, 2015
… Templating component (Koc)

This PR was squashed before being merged into the 2.8 branch (closes #15620).

Discussion
----------

[WIP] #15502 Make template shortcuts be usable without Templating component

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | ?
| Fixed tickets | #15502
| License       | MIT
| Doc PR        | -

Commits
-------

d547ec0 [WIP] #15502 Make template shortcuts be usable without Templating component
@Koc
Copy link
Contributor

Koc commented Sep 14, 2015

Please do not close this ticket because some other features are missing, loke Stopwatch integration.

@fabpot
Copy link
Member

fabpot commented Sep 14, 2015

@Koc Can you create another issue for Stopwatch? and close this one because this one is not about Stopwatch (except if you carefully read the whole discussion :)).

@Koc
Copy link
Contributor

Koc commented Sep 14, 2015

Ok, will do

@fabpot fabpot closed this as completed Sep 14, 2015
fabpot added a commit that referenced this issue Sep 14, 2015
* 2.8: (31 commits)
  [DomCrawler] Invalid uri created from forms if base tag present
  [VarDumper] Add caster for OuterIterator objects
  [Console] update param type phpdoc for StreamOutput
  [Console] fix typo in OutputInterface
  Use stderr by default when a specific output is not injected
  fixed bad merge
  [Debug] Fix case mismatch detection
  [HttpKernel] Add entry point to more easily create/configure the DI extension
  [DX] Added a logout link in the security panel of the web debug toolbar
  [HttpKernel] fix broken multiline <esi:remove>
  [DoctrineBridge] Fixed #14840
  [FrameworkBundle] add a suggest for the serializer component
  fixed CS
  removed non-working tests
  [WIP] #15502 Make template shortcuts be usable without Templating component
  Redesigned the Symfony Profiler
  [Yaml] Fix the parsing of float keys
  Make the exception output visible even in quiet mode, fixes #15680
  Convert Output::write's type to an options arg where verbosity can be passed in as well
  [Console] Ensure the console output is only detected as decorated when both stderr and stdout support colors
  ...
fabpot added a commit that referenced this issue Dec 23, 2016
…the Templating component (dunglas)

This PR was merged into the 2.8 branch.

Discussion
----------

[FrameworkBundle] Make TemplateController working without the Templating component

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

The template controller was missed during #15502. Btw I've added some tests for this controller.

Commits
-------

89ccbc4 [FrameworkBundle] Make TemplateController working without the Templating component
ostrolucky pushed a commit to ostrolucky/symfony that referenced this issue Mar 25, 2018
* 2.8: (31 commits)
  [DomCrawler] Invalid uri created from forms if base tag present
  [VarDumper] Add caster for OuterIterator objects
  [Console] update param type phpdoc for StreamOutput
  [Console] fix typo in OutputInterface
  Use stderr by default when a specific output is not injected
  fixed bad merge
  [Debug] Fix case mismatch detection
  [HttpKernel] Add entry point to more easily create/configure the DI extension
  [DX] Added a logout link in the security panel of the web debug toolbar
  [HttpKernel] fix broken multiline <esi:remove>
  [DoctrineBridge] Fixed symfony#14840
  [FrameworkBundle] add a suggest for the serializer component
  fixed CS
  removed non-working tests
  [WIP] symfony#15502 Make template shortcuts be usable without Templating component
  Redesigned the Symfony Profiler
  [Yaml] Fix the parsing of float keys
  Make the exception output visible even in quiet mode, fixes symfony#15680
  Convert Output::write's type to an options arg where verbosity can be passed in as well
  [Console] Ensure the console output is only detected as decorated when both stderr and stdout support colors
  ...
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

6 participants