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

Skip to content

[symfony/twig-bundle] remove "paths", thats already the default #416

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
wants to merge 1 commit into from
Closed

[symfony/twig-bundle] remove "paths", thats already the default #416

wants to merge 1 commit into from

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Jun 5, 2018

Q A
License MIT

since 3.4 at least, but 3.3 is EOLed.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request passes validation.

@nicolas-grekas nicolas-grekas changed the title Twig no path [symfony/twig-bundle] remove "paths", thats already the default Jun 5, 2018
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request passes validation.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request passes validation.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request passes validation.

@xabbuh
Copy link
Member

xabbuh commented Jun 12, 2018

We could copy the existing recipe to make this on only available for 3.4 and up even if 3.3 is not maintained anymore (but we then just wouldn't do any updates anymore for the 3.3 recipe).

@weaverryan
Copy link
Member

I kinda like this config: it’s nice to say “why do templates live here? Check out this config!”. And then you easily know how to add more paths.

I’m kind of a fan of including more config than we need in these files (but probably commented out with default values, most of the time).

So, I think the DX is better WITH the config. Wdyt?

@nicolas-grekas
Copy link
Member Author

Errors are odd right now: the path is mentioned two times...

@xabbuh
Copy link
Member

xabbuh commented Jun 16, 2018

Well, we could also think about improving the error message instead (i.e. checking if the default path is also part of the other configured paths?).

@nicolas-grekas
Copy link
Member Author

Maybe enhance the registration logic? The error message is accurate about what happens under the hood so this should remain :)

@yceruto
Copy link
Member

yceruto commented Jun 20, 2018

Maybe Twig shouldn't add the same namespace/path twice.

@yceruto
Copy link
Member

yceruto commented Jun 20, 2018

I kinda like this config: it’s nice to say “why do templates live here? Check out this config!”.

If we want to keep this config, what about to show the default_path instead? That's where it really lives.

@nicolas-grekas
Copy link
Member Author

Related to symfony/symfony#27728 I suppose?

@yceruto
Copy link
Member

yceruto commented Jun 26, 2018

I think this is a diffent issue, actually we're adding the root templates directory twice:
debug_twig_recipe

It's necessary only for 3.3, since 3.4 this path is already added through twig.default_path option. I bet for #416 (comment) + #416 (comment):

twig:
    default_path: '%kernel.project_dir%/templates'

even if it's the default value.

@nicolas-grekas
Copy link
Member Author

(3.3 is EOLed so we don't really care for it)

@yceruto
Copy link
Member

yceruto commented Jun 26, 2018

and we need to do the same for translation recipe, for consistency I guess?:

translator:
paths:
- '%kernel.project_dir%/translations'

It has default_path option too since 3.4.

@fabpot
Copy link
Member

fabpot commented Jul 11, 2018

I agree that having this setting even if that's the default value is nice. Let's close.

@fabpot fabpot closed this Jul 11, 2018
@yceruto
Copy link
Member

yceruto commented Jul 11, 2018

@fabpot but behind this there is a problem:

  • The default path is displayed twice for "Unable to find template" exception:

    Unable to find template "form/layoutt.html.twig" (looked into: /home/yceruto/github/symfony/symfony-demo/templates, /home/yceruto/github/symfony/symfony-demo/templates, /home/yceruto/github/symfony/symfony-demo/vendor/symfony/twig-bridge/Resources/views/Form).

  • And debug:twig command shows:

     Loader Paths
     ------------
    
      --------------- ------------------------------------------------------ 
       Namespace       Paths                                                 
      --------------- ------------------------------------------------------ 
                                                                         
       (None)          - templates                                           
                       - templates                                           
                       - vendor/symfony/twig-bridge/Resources/views/Form 

Edit: See alternative #434 to solve it.

@fabpot
Copy link
Member

fabpot commented Jul 12, 2018

@yceruto I know, but that's something we need to fix on the Symfony side.

@yceruto
Copy link
Member

yceruto commented Jul 12, 2018

@fabpot that means we should avoid to add the same path twice in the Twig loader?

@fabpot
Copy link
Member

fabpot commented Sep 3, 2018

@yceruto Probably, yes

@nicolas-grekas nicolas-grekas deleted the twig-no-path branch September 5, 2018 13:40
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

Successfully merging this pull request may close these issues.

6 participants