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

[TwigComponent] Minimal support of comment lines #2464

Open
wants to merge 2 commits into
base: 2.x
Choose a base branch
from

Conversation

smnandre
Copy link
Member

Twig introduced the inline comments in twigphp/Twig#4349

This PR add minimal support for it the PreLexer / HTML syntax

<twig:Button
    # comment
    bar="bar"
/>

I'd like some IRL feedbacks on this one :)

Twig introduced the inline comments in twigphp/Twig#4349

This PR add minimal support for it the PreLexer / HTML syntax

```twig
<twig:Button
    # comment
    bar="bar"
/>
```

I'd like some IRL feedbacks on this one :)
Twig introduced the inline comments in twigphp/Twig#4349

This PR add minimal support for it the PreLexer / HTML syntax

```twig
<twig:Button
    # comment
    bar="bar"
/>
```

I'd like some IRL feedbacks on this one :)
Copy link
Member

@Kocal Kocal left a comment

Choose a reason for hiding this comment

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

Cool!

I don't have real use-cases from the projets I'm working on, but I believe it will be super-useful (even if I believe some comments can be avoid by using good attribute's name or variable!)

However, introducing a new syntax means that tools manipulating ASTs (like IDEs, Twig-CS-Fixer, maybe TwigStan, and syntax highlighting) will break, right?

@smnandre
Copy link
Member Author

Not at all, they already are compatible. I'm just following Twig syntax here, not adding anything new. But that means adapting the PreLexer we use to convert HTML Syntax into regular Twig code :)

@Kocal
Copy link
Member

Kocal commented Dec 23, 2024

I mean, for tools that does not use our PreLexer.

I've tested with Twig-CS-Fixer and no issues so far, but I think it does not support Twig Component at all.
I don't know about TwigStan (which I believe indirectly use our PreLexer).

But, for syntax coloration it does not work, and I don't know who/when this new syntax will be added to IDE and other syntax coloration libraries:
image

@smnandre
Copy link
Member Author

I've tested with Twig-CS-Fixer and no issues so far, but I think it does not support Twig Component at all.

They do, and they integrated inline comments right after Twig release :)

But, for syntax coloration it does not work, and I don't know who/when this new syntax will be added

Me neither but... how is this related to this PR ? :) I'm genuinely not sure to get the questions here.

Twig syntax changes are generally pretty quickly integrated into PhpStorm Twig integration (or in the Symfony plugin).

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

Successfully merging this pull request may close these issues.

3 participants