8000 [Profiler] HTML comments for twig blocks · Issue #32175 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Profiler] HTML comments for twig blocks #32175

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
shyim opened this issue Jun 25, 2019 · 7 comments
Closed

[Profiler] HTML comments for twig blocks #32175

shyim opened this issue Jun 25, 2019 · 7 comments

Comments

@shyim
Copy link
Contributor
shyim commented Jun 25, 2019

Description
When a project has huge amount of template files and a new developer has to change something in template, he will search long to find the location he wants to modify. I developed a new NodeVisitor which adds html comments for starting and ending a block. This helps to see directly in developer console, which file has to be modified.

Maybe it's a good addition to the profiler bundle, to toggle such html comments. What are you thinking?

Example

@ro0NL
Copy link
Contributor
ro0NL commented Jun 25, 2019

I tried something similar here #28056, but it has some edge cases for twig not being a HTML only template engine. I don't think we can anticipate it ... but feel to share your implementation :)

@shyim
Copy link
Contributor Author
shyim commented Jun 25, 2019

My solution was to add a config to toggle the comments and config with an array of regex to blacklist some types of blocks.

Example:
We normally end a block which is in a html attribute with suffix attributes. So this could be done with a simple regex.

@stof
Copy link
Member
stof commented Jun 26, 2019

And even in HTML templates, we could have blocks in places where adding a comment is not possible (I often have a block inside a class attribute in a parent template, to allow child templates to add classes on <body> for instance).

@shyim
Copy link
Contributor Author
shyim commented Jun 26, 2019

This could be solved with a blacklist, which can be also extended

@fabpot
Copy link
Member
fabpot commented Jun 26, 2019

I suggest that this feature is implemented outside of core first.

@ro0NL
Copy link
Contributor
ro0NL commented Jun 26, 2019

@shyim the main problem is the weight put on upstream vendors. By default any template can be crashing, and the white/blacklist maintenance proliferates.

@javiereguiluz
Copy link
Member

@shyim even we like your idea, we think it's not "possible" to implement it in a generic way for the comments added above (not all templates are HTML, there are too many edge-cases where these comments shouldn't be added even when using HTML, etc.)

So, let's try to implement this outside of Symfony in a third-party package and depending on the results, we can reconsider this decision. Meanwhile, let's close this until we have those results. Thanks for understanding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants
0