Convert HTML tags to PHP

Hi,

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

 

Example:

<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...

3 comments
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

0
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...

 

0
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

0

Please sign in to leave a comment.