arzumy
8/25/2010 - 2:36 AM

Change HTML attr to symbol

#!/usr/bin/env ruby
# Textmate bundle command to change HTML attr to symbol
# I normally use this when working with html files from designer
# so line like this id="logo" class="left" converted to , :id => "logo", :class => "left"

def to_options(str)
  str.gsub(/((\s|^)(\w+))(=)/i)  {|v| ", :#{$3} #{$4}> "}
end

print to_options(STDIN.read)