-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Documenting debug:twig command #10232
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
Conversation
…wig command to find their paths (yceruto) This PR was squashed before being merged into the 4.2-dev branch (closes #27981). Discussion ---------- [TwigBridge] Added template "name" argument to debug:twig command to find their paths | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #27911 | License | MIT | Doc PR | symfony/symfony-docs#10232 Find the template file (to load by Twig) from a given template name (useful to know which file will be loaded exactly and which ones don't):  This will also show the overridden files if they exist and the paths corresponding to their namespace. In addition, the command suggests alternatives if you made a typo (this way you can check your template name quickly): | namespace typo | template name typo | | --- | --- | |  |  | <details> <summary><strong>Other outputs</strong></summary> Discovering more alternatives:  Unknown template name:  </details> ## Update The feature was introduced into `debug:twig` command and the `filter` argument was converted to `--filter` option. The `name` argument is now the first one of the command. Commits ------- 7ef3d39a4c [TwigBridge] Added template \"name\" argument to debug:twig command to find their paths
…wig command to find their paths (yceruto) This PR was squashed before being merged into the 4.2-dev branch (closes #27981). Discussion ---------- [TwigBridge] Added template "name" argument to debug:twig command to find their paths | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #27911 | License | MIT | Doc PR | symfony/symfony-docs#10232 Find the template file (to load by Twig) from a given template name (useful to know which file will be loaded exactly and which ones don't):  This will also show the overridden files if they exist and the paths corresponding to their namespace. In addition, the command suggests alternatives if you made a typo (this way you can check your template name quickly): | namespace typo | template name typo | | --- | --- | |  |  | <details> <summary><strong>Other outputs</strong></summary> Discovering more alternatives:  Unknown template name:  </details> ## Update The feature was introduced into `debug:twig` command and the `filter` argument was converted to `--filter` option. The `name` argument is now the first one of the command. Commits ------- 7ef3d39 [TwigBridge] Added template \"name\" argument to debug:twig command to find their paths
Related PR was merged 🎉 now we can take care of this one :) Cheers! |
@@ -71,6 +71,13 @@ in the ``vendor/acme/foo-bar/templates/`` directory, you can refer to it as: | |||
|
|||
{{ include('@foo_bar/sidebar.twig') }} | |||
|
|||
Execute this command to verify if your template name is correct and know which | |||
template file will be loaded: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just asking: what happens if the app doesn't use physical files to store templates? (they are stored in the database for example)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly, at this moment, the command only work for physical files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, I'm not sure if the TwigBridge
& TwigBundle
support such feature.
templating/debug.rst
Outdated
# filter output by any keyword | ||
$ php bin/console debug:twig --filter=date | ||
|
||
Also, you can verify any template name to know which template file will be loaded: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can merge this last comment into the main code block?
.. code-block:: terminal
...
# pass a template path to show the physical file which will be loaded
$ php bin/console debug:twig @Twig/Exception/error.html.twig
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks!
b36f615
to
621a846
Compare
621a846
to
1026020
Compare
This PR was merged into the master branch. Discussion ---------- Documenting debug:twig command See symfony/symfony#27981 Commits ------- 1026020 Documenting debug:twig command
This was finally merged. Yonel, thanks as always for creating these great little utilities to improve developer experience! |
See symfony/symfony#27981