Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Check if templating engine supports given view #40373

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

Merged
merged 1 commit into from
Mar 12, 2021

Conversation

fritzmg
Copy link
Contributor

@fritzmg fritzmg commented Mar 5, 2021

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

Currently the ControllerTrait::render and ControllerTrait::renderView methods assume that when the templating service is available it can always render the given view via that service.

However, that might not be the case. For example if framework.templating is not configured to support the twig engine for example but only some other custom engine, e.g.

framework:
  templating:
    engines: 
      - foobar

it will fail when the given view references a Twig template for instance and the configured engine cannot render that.

The Symfony\Component\Templating\EngineInterface which templating implements defines a support method:

/**
* Returns true if this class is able to render the given template.
*
* @param string|TemplateReferenceInterface $name A template name or a TemplateReferenceInterface instance
*
* @return bool true if this class supports the given template, false otherwise
*/
public function supports($name);

which should be used here, in order to make sure that templating actually does support rendering the given view.

@fabpot
Copy link
Member

fabpot commented Mar 12, 2021

Thank you @fritzmg.

@fabpot fabpot merged commit fb670df into symfony:4.4 Mar 12, 2021
@fritzmg fritzmg deleted the fix-template-engine-rendering branch March 12, 2021 09:27
This was referenced Mar 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.