Skip to content

Instantly share code, notes, and snippets.

@nissuk
Created November 11, 2011 10:35
Show Gist options
  • Save nissuk/1357699 to your computer and use it in GitHub Desktop.
Save nissuk/1357699 to your computer and use it in GitHub Desktop.
Aptana Studio 3.0.6: メニューのCommands > HAML にHAML形式をHTML形式に変換するメニューを追加する
=begin
適用方法
1. Commands > HAML > Edit this bundle を開く
2. 出てきたプロジェクトのbundle.rbに main_menu.command 'Convert HAML to HTML' を追加する
3. このコードを commands/convert_haml_to_html.rb に保存する
4. Aptanaを再起動する
=end
require 'ruble'
#command 'Convert HTML to HAML' do |cmd|
command 'Convert HAML to HTML' do |cmd|
# cmd.key_binding = 'M1+M3+C' # Alt + Cmd not friendly for overseas users
cmd.output = :replace_selection
cmd.input = :selection, :document
cmd.invoke do |context|
#cmd_line = "ruby -e \"require 'rubygems'; gem 'haml'; require 'haml/html'; puts Haml::HTML.new(STDIN.read).render\""
cmd_line = "ruby -e \"require 'rubygems'; gem 'haml'; require 'haml/html'; puts Haml::Engine.new(STDIN.read).render\""
output = IO.popen(cmd_line, 'r+') do |io|
io << $stdin.read
io.close_write
io.read
end
if output.nil? or output.strip.length == 0
context.exit_show_tooltip "No output. May need to install haml or hpricot gem. hpricot must be installed through Ruby devkit's msys prompt!" if Ruble.is_windows?
context.exit_discard
end
output
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment