Skip to content
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

[FR] Add support for {% include %} back into the plugin #40

Closed
CreateSean opened this issue May 24, 2022 · 9 comments
Closed

[FR] Add support for {% include %} back into the plugin #40

CreateSean opened this issue May 24, 2022 · 9 comments
Labels
enhancement New feature or request

Comments

@CreateSean
Copy link

CreateSean commented May 24, 2022

Describe the bug

A clear and concise description of what the bug is.

Template comments is not working with matrix blocks in new versions

image

In the screenshot the circled sections are each a matrix block but template comments is not telling me where they are located.


However in a different older site running Craft 3.7.37 and Template Comments 1.1.2 matrix blocks output comments as expected. See below.
image

To reproduce

Steps to reproduce the behaviour:

  1. Go to "..."
  2. Click on "..."
  3. See error message "..."

Expected behaviour

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Versions

  • Plugin version: 1.2.0
  • Craft version: 3.7.42
@CreateSean CreateSean added the bug Something isn't working label May 24, 2022
@khalwat
Copy link
Contributor

khalwat commented May 24, 2022

Not exactly a bug, but not something you're likely to be happy about... due to compatibility with Twig 3 reasons, I removed the template loader shim that allowed those template delimiters.

You can still pin it to the older version of the plugin for Craft 3 if you want to keep that functionality. Maybe I'll figure out a better way to do it going forward.

Here's a good description from @MangoMarcus #43

Question

Is there no support for comments when using {% include %} ?

This plugin works well for {% block %} but the description to me implies it would cover using {% include %}

Adds a HTML comment to demarcate each Twig template that is included or extended.

eg. using {% include '_foo/my-template' %} I'd expect something like

<!-- >>> INCLUDE BEGIN >>> _foo/my-template FROM _foo/other-template -->
<!-- * template output here * -->
<!-- <<< INCLUDE END <<< _foo/my-template FROM _foo/other-template TIME 1.23ms -->

Thanks!

@CreateSean
Copy link
Author

CreateSean commented May 24, 2022

Oh... :(

so this is removed in the Craft 4 compatible version, right? What is the most recent version that still has the delimiters? I'll lock to that in my C3 projects.

I'll wait until you figure out the better approach. Love this plugin alot.

@khalwat
Copy link
Contributor

khalwat commented May 24, 2022

The Craft 4 / Twig 3 version does not log comments for {% include %}s -- but rather only {% block %}s (but those now include the template they are coming from).

The latest version of the Craft 3 plugin is at feature parity with the Craft 4 version, which means you lose the {% include %} comments. If you want to lock in the Craft 3 version that does add {% include %} comments, set your semver to 1.1.2.

No ETA on adding this functionality back into the Craft 4 version of the plugin; it'll have to wait until work settles down a bit on the other plugins.

@johnwbaxter
Copy link

I just came here to report this bug! This was what I used this plugin for, for looking at which block from my content builder was doing what and where :)

Really hope it comes back soon! Thanks Andrew!! :)

@taya13
Copy link

taya13 commented Sep 19, 2022

Indeed I was also using this plugin for generating comments for includes...
I also hope it will come back soon

@khalwat
Copy link
Contributor

khalwat commented Apr 16, 2024

Same as #43

@khalwat khalwat changed the title Not working with matrix blocks [FR] Add support for {% include %} back into the plugin Apr 16, 2024
@khalwat khalwat added enhancement New feature or request and removed bug Something isn't working labels Apr 16, 2024
@khalwat
Copy link
Contributor

khalwat commented Apr 18, 2024

So I got this working for Craft 4 (really, for Twig 3.0)... and man it's ugly. But it works.

I'm going to think about it for a bit to see if there are better approaches

khalwat added a commit that referenced this issue Apr 18, 2024
@khalwat
Copy link
Contributor

khalwat commented Apr 18, 2024

Here's the commit in question: 3b6b991

...with a detailed explanation of the problem here: https://github.com/nystudio107/craft-templatecomments/blob/develop-v4/src/web/twig/TemplateCommentsParser.php#L11

khalwat added a commit that referenced this issue Apr 18, 2024
@khalwat
Copy link
Contributor

khalwat commented Apr 19, 2024

1.2.1, 4.0.1, & 5.0.0 released with this FR added

@khalwat khalwat closed this as completed Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants