Skip to content

[TwigBridge] Fix missing path and separators in loader paths list on debug:twig output #27728

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
Jul 7, 2018

Conversation

yceruto
Copy link
Member

@yceruto yceruto commented Jun 26, 2018

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

Reproducer

$ composer create-project symfony/skeleton repr
$ cd repr
$ composer req twig
# remove duplicated path on `twig.paths: ['%kernel.project_dir%/templates']` config.
$ bin/console debug:twig

See "Loader Paths" section at the end of the output and compare it with --format=json. Note that the root templates path is present in Twig loader_paths because twig.default_path config, but it isn't visible on debug:twig output.

Missing path:

Before After
debug_twig_before1 debug_twig_after1

Extra Lines separator:

Before After
debug_twig_before2 debug_twig_after2

@yceruto
Copy link
Member Author

yceruto commented Jun 26, 2018

(Travis failures unrelated)

{
$tester = $this->createCommandTester(array(
'Acme' => array('extractor', 'extractor'),
'!Acme' => array('extractor', 'extractor'),
Copy link
Member

Choose a reason for hiding this comment

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

I suggest using different paths for some of them, to make the test a bit more realistic

Copy link
Member Author

@yceruto yceruto Jun 26, 2018

Choose a reason for hiding this comment

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

Right, but that would require create an empty directory (with .gitignore file) into Fixtures (root path), anyway they are fakes paths to show the line separator, it still worth it?

Copy link
Member Author

Choose a reason for hiding this comment

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

I added a comment to avoid any confusion when reading the code.

@fabpot
Copy link
Member

fabpot commented Jun 27, 2018

I have a hard time (and I know that this is not really related to this PR) figuring out why/when we have empty lines. Can someone explain that to me?

@yceruto
Copy link
Member Author

yceruto commented Jun 27, 2018

@fabpot empty lines (or namespace separator) was proposed in the original PR #24064 (comment) to solve some kind of cluttering in the original design of the table when there is more than one path per namespace #24064 (comment), but still we can reopen that discussion if you prefer remove these empty lines or another variant from #24064 (comment).

@javiereguiluz
Copy link
Member

I don't mind the new lines (I think it makes this more readable) but I'd like to propose two tweaks for your consideration:

  1. Remove the leading - before each path
  2. Add a trailing / to all paths to clearly show that they are directories.

This is how it'd look:

Before

 --------------- ------------------------------------------------------
  Namespace       Paths
 --------------- ------------------------------------------------------
  @Framework      - vendor/symfony/framework-bundle/Resources/views
  @!Framework     - vendor/symfony/framework-bundle/Resources/views
  @Security       - vendor/symfony/security-bundle/Resources/views
  @!Security      - vendor/symfony/security-bundle/Resources/views
  ...             ...
 --------------- ------------------------------------------------------

After

 --------------- ------------------------------------------------------
  Namespace       Paths
 --------------- ------------------------------------------------------
  @Framework      vendor/symfony/framework-bundle/Resources/views/
  @!Framework     vendor/symfony/framework-bundle/Resources/views/
  @Security       vendor/symfony/security-bundle/Resources/views/
  @!Security      vendor/symfony/security-bundle/Resources/views/
  ...             ...
 --------------- ------------------------------------------------------

@yceruto
Copy link
Member Author

yceruto commented Jun 28, 2018

Javier about:

  1. Remove the leading - before each path
  2. Add a trailing / to all paths to clearly show that they are directories.

Look good to me.

@yceruto yceruto force-pushed the debug_twig_command branch from 4b5e29d to 4336f45 Compare June 28, 2018 18:11
@yceruto
Copy link
Member Author

yceruto commented Jul 7, 2018

Any update about this? We are all good with the empty lines as namespace separator? thanks.

@nicolas-grekas
Copy link
Member

Thank you @yceruto.

@nicolas-grekas nicolas-grekas merged commit ba7a4ca into symfony:3.4 Jul 7, 2018
nicolas-grekas added a commit that referenced this pull request Jul 7, 2018
…hs list on debug:twig output (yceruto)

This PR was squashed before being merged into the 3.4 branch (closes #27728).

Discussion
----------

[TwigBridge] Fix missing path and separators in loader paths list on debug:twig output

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

**Reproducer**
```bash
$ composer create-project symfony/skeleton repr
$ cd repr
$ composer req twig
# remove duplicated path on `twig.paths: ['%kernel.project_dir%/templates']` config.
$ bin/console debug:twig
```
See "Loader Paths" section at the end of the output and compare it with `--format=json`. Note that the root `templates` path is present in Twig `loader_paths` because `twig.default_path` config, but it isn't visible on `debug:twig` output.

**Missing path:**

| Before | After |
| --- | --- |
| ![debug_twig_before1](https://user-images.githubusercontent.com/2028198/41908937-9af78274-7913-11e8-91d1-bb48f81031dd.png) | ![debug_twig_after1](https://user-images.githubusercontent.com/2028198/41908969-b5fd3140-7913-11e8-8129-8215f3c09b24.png) |

**Extra Lines separator:**

| Before | After |
| --- | --- |
| ![debug_twig_before2](https://user-images.githubusercontent.com/2028198/41909029-e867fcdc-7913-11e8-91f1-bba0d873495c.png) | ![debug_twig_after2](https://user-images.githubusercontent.com/2028198/41915586-12a6426e-7924-11e8-899f-9ecc7d95b74f.png) |

Commits
-------

ba7a4ca [TwigBridge] Fix missing path and separators in loader paths list on debug:twig output
@yceruto yceruto deleted the debug_twig_command branch July 7, 2018 15:13
This was referenced Jul 23, 2018
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.

6 participants