Skip to content

Fixed the rendering of exceptions inside the profiler #22491

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
Apr 22, 2017

Conversation

javiereguiluz
Copy link
Member

@javiereguiluz javiereguiluz commented Apr 20, 2017

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

In #22448 we tried to reuse the same CSS styles as the new exception pages. But that's not enough because it doesn't look good:

before


This PR goes a bit further and tweaks the exception styles slightly to better integrate them. Same page as before:

after_1

It should also work reasonably well when the exception message is very long:

after_2

.hidden { display: none; }
.nowrap { white-space: nowrap; }
.newline { display: block; }
.break-long-words { -ms-word-break: break-all; word-break: break-all; word-break: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; }
Copy link
Contributor

Choose a reason for hiding this comment

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

please check word-break value. it looks strange
https://developer.mozilla.org/en-US/docs/Web/CSS/word-break

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right that it looks weird ... but apparently that's the only way to make this work for every browser, as shown here: https://css-tricks.com/almanac/properties/w/word-break/

Copy link
Contributor

Choose a reason for hiding this comment

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

oh, I see. good to know, thanks

@fabpot
Copy link
Member

fabpot commented Apr 22, 2017

Thank you @javiereguiluz.

@fabpot fabpot merged commit 73d81de into symfony:master Apr 22, 2017
fabpot added a commit that referenced this pull request Apr 22, 2017
…iereguiluz)

This PR was merged into the 3.3-dev branch.

Discussion
----------

Fixed the rendering of exceptions inside the profiler

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

In #22448 we tried to reuse the same CSS styles as the new exception pages. But that's not enough because it doesn't look good:

![before](https://cloud.githubusercontent.com/assets/73419/25250100/a287b4bc-2614-11e7-88e7-e0ef89eac1ff.png)

---

This PR goes a bit further and tweaks the exception styles slightly to better integrate them. Same page as before:

![after_1](https://cloud.githubusercontent.com/assets/73419/25250131/b8d16cf4-2614-11e7-93b4-187248849103.png)

It should also work reasonably well when the exception message is very long:

![after_2](https://cloud.githubusercontent.com/assets/73419/25250144/c25eab38-2614-11e7-99e2-843548d12810.png)

Commits
-------

73d81de Fixed the rendering of exceptions inside the profiler
@sustmi
Copy link
Contributor

sustmi commented Apr 22, 2017

@javiereguiluz: Why does the new CSS file have twig extension (src/Symfony/Bundle/TwigBundle/Resources/views/exception.css.twig) when it is just plain static CSS file that does not need Twig mark-up?

@sustmi
Copy link
Contributor

sustmi commented Apr 22, 2017

Oh, I see: include() function is for including templates.

.sf-reset .traces li.selected {
background: rgba(255, 255, 153, 0.5);
}
{{ include('@Twig/exception.css.twig') }}
Copy link
Contributor

@sustmi sustmi Apr 22, 2017

Choose a reason for hiding this comment

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

Why you did not use {{ source('@Twig/exception.css') }}?
I think that the CSS file is not supposed to be a template.

Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC you can't include a non Twig template in Twig. Remember this is not php include but uses the Twig loader to find and load files.

Copy link
Contributor

@sustmi sustmi Apr 22, 2017

Choose a reason for hiding this comment

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

According to the source() function documentation:

The source function returns the content of a template without rendering it

The function uses the same template loaders as the ones used to include templates. So, if you are using the filesystem loader, the templates are looked for in the paths defined by it.

Isn't this what we need?

Copy link
Member Author

Choose a reason for hiding this comment

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

We can use either include() or source(). And the file can be .css or .css.twig. Everything will work 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, both functions will put the CSS code in the HTML in the end. My point is that include() is trying to parse the CSS file as Twig which is not needed.

It is similar to having an index.php file that contains HTML page and wants to in-line some CSS by calling require 'theme.css.php' in the header (where theme.css.php is a plain CSS file and does not contain any PHP) instead of just echo file_get_contents('theme.css') or readfile('theme.css').

But after all it's only detail so lets not expend any more time on it. Thanks for fixing the exception page in the profiler.

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