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

Inject PHP code without PHP tags #168

Closed
calebdw opened this issue Feb 21, 2023 · 1 comment · Fixed by #192
Closed

Inject PHP code without PHP tags #168

calebdw opened this issue Feb 21, 2023 · 1 comment · Fixed by #192

Comments

@calebdw
Copy link
Collaborator

calebdw commented Feb 21, 2023

Hello!

I'm trying (somewhat unsuccessfully, but trying nonetheless) to write a parser for the Laravel Blade templating system. I've captured the code content between the output directives (e.g., {{ $fooBar->some_attribute }}) but when I inject the content the parser thinks it ($fooBar->some_attribute) is just text.

If I do the following then the parser recognizes it as a variable and properly highlights it, however, this defeats the whole purpose of the templating system:
{{ <?php $fooBar->some_attribute ?> }}

Something similar occurs in markdown file with PHP fenced content:

E.g., here the php parser thinks the content is just text
image

whereas it's a variable assignment with the php tags
image

Is there a way to have the parser recognize the content as php without explicitly declaring the php tags?

Thanks!

@calebdw
Copy link
Collaborator Author

calebdw commented May 30, 2023

It looks like the Go parser allows statements at the top level for this very reason (tree-sitter/tree-sitter-go#63).

I'll submit a PR to do the same with this parser.

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