Using Regex in Textmate to convert HTML comments to Ruby comments

To cut down on space, I felt it would be easy enough to convert HTML comments to Ruby comments, so I looked for a way to do this site-wide.

Using the Regex option in textmate’s “find in project” utility will get you the results you need.

Using a simple RegEx…

<!--(.*)-->

and then using the replace

<%#$1%>

Will convert ALL HTML comments to ruby comments.

Warning..  if you have ruby inside an HTML comment, this could prove disasterous..  ie.

<!--<a href="<%= variable_name %>">a link</a>-->

Or, if you use comment shorthand. (so I like to call it.)

<!--a href="blah.html">a link</a-->

Oh!  and uh.. don’t forget to check the option for Regular expressions..  or else it wont work at all.   hah!

This entry was posted in Uncategorized, rails, webdev. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>