[TxMt] PHP Commenting Out Command

Steven Ross cwdinfo at gmail.com
Thu Oct 5 19:32:32 UTC 2006


I'm working on a Wordpress blog and sometimes need to comment out  
blocks of intermingled PHP and HTML. Don't get me started on either  
PHP or interspersing code and markup. Anyhow, here's a hackish  
command that toggles an if(false) block:

#!/usr/bin/env ruby

lines = STDIN.readlines

php_regex = /\<\?php/i

if lines[0] =~ php_regex
	lines.each{|l| puts l unless l =~ php_regex}
else
	puts '<?php if(false) { ?>'
	lines.each{|l| puts l}
	puts '<?php } ?>'
end

Hope this is useful to someone...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20061005/91a4c138/attachment.html>


More information about the textmate mailing list