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

[RFC] Deprecate the removal of 'Bundle' suffix in Twig paths #20130

Copy link
Copy link
Closed
@javiereguiluz

Description

@javiereguiluz
Issue body actions

Context

This method of the TwigBundle removes the Bundle suffix before adding them as Twig paths. So in your templates:

{# it works #}
{% extends '@App/Default/index.html.twig' %}

{# it doesn't work #}
{% extends '@AppBundle/Default/index.html.twig' %}

Problem

  • In the particular case of the AppBundle, the @App/... notation may be confusing because you may not be sure if it refers to app/... or src/AppBundle/...
  • This behavior is not consistent in Symfony (everywhere else you must add the Bundle suffix):
    • For example, to load resources in routing:

      # it works
      resource: "@AppBundle/Controller/"
      
      # it doesn't work
      resource: "@App/Controller/"
    • The old "bundle notation" also requires the Bundle prefix:

      {# it works #}
      {{ render(controller('AppBundle:Article:recentArticles')) }}
      
      {# it doesn't work #}
      {{ render(controller('App:Article:recentArticles')) }}

In summary, the automagical removal of the Bundle suffix makes developers think: which is the right notation for this? Should I add the Bundle suffix or not?

Proposal

  • I propose to remove this feature and always use the Bundle suffix everywhere.
  • Although you now would type 6 more characters, I think it's worth it to avoid confusion and improve consistency.
  • If accepted, first I'd add both paths (with and without Bundle) but deprecate the Twig paths without the Bundle suffix. Then I'd remove the suffix-less paths in Symfony 4.0.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCRFC = Request For Comments (proposals about features that you want to be discussed)RFC = Request For Comments (proposals about features that you want to be discussed)TwigBundle

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

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