Autoinject HTML into echo
Hello,
it would be really useful to have HTML injected right after I type (in PHP file) and have caret inside quotes:
echo "";
So I can write emmet and have tags autocompleted right away, so there is no need to write at least one tag to have HTML injected. This will help speed up work great, because mostly I need to work with HTML when echoing. It might be useful when defining variables as well.
Can you please help me how to achieve this in PhpStorm? I believe this would be usefull for many other users too. I was looking into how Injections are defined, into documentation and into PSI Viewer, but didn't find how to do it properly.
Thank you
Please sign in to leave a comment.
Is your main goal to inject HTML into any string in the PHP context?
If so, you can copy the
php: "<html>"
injection pattern atSettings/Preferences | Editor | Language Injections
and replace the pattern with:Unfortunately, I don't know if there's a way to check for the
echo
call before the string, or for single/double quotes.Please let me know whether the suggested solution works for you or not.
Hello Eugune,
yes! Thank you, I tried it right away and it works how I imagined.
Not sure if this could cause unexpected behavior elsewhere, hopefully not.
Thank you again for your help, great support.
Nice! By the way, I asked a developer for help, and he came up with the following pattern that only injects HTML for
echo
statements.Oh my, even better! Solution you provided before affected strings that were before correctly injected as MySQL etc. It was not a big deal for me, but this would be much better.
I already tried this new one and it works just perfect.
You rock!
I believe this would be helpful for many other developers as well. Scenario when you write echo (print...) and then you want to use HTML/Emmet completion right away is pretty common.