Convert HTML tags to PHP


Is there any way to simple select line of code in HTML and convert it to PHP ?



<div style="color:red;" id="test_id">test</div>

...simple convert to:

echo "<div style=\"color:red;\" id=\"test_id\">test</div>";


Any idea? 

Maybe by Live Surround Template, but how to replace " to \"


Thanks for replies...

Comment actions Permalink

You can create a live template for this, like:

where $HTML$ is

regularExpression(clipboard(), "\\s*\\\"\\s*", "\\\\\"")



to apply the template, select and copy your HTML tag to clipboard and then enter your template abbreviation and hit Tab

Comment actions Permalink

Thanks for reply.

It is almost what i need :)


Can i use $SELECTION$ insteed of clipboard?

The perfect thing for me will be selecting HTML tag and then use live template...


Comment actions Permalink

>Can i use $SELECTION$ insteed of clipboard?

no - there are no predefined live template functions for $SELECTION$, so you can't use it in your expression. Plus, this macro only works in surround templates - and you aren't going to surround your HTML code with echo statements, you need to transform it instead.

You can use Find/Replace with regexp to replace your HTML code


Please sign in to leave a comment.