Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

60 lines (53 sloc) 1.777 kB
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env ruby -w
require "#{ENV["TM_SUPPORT_PATH"]}/lib/escape"
require "enumerator"
TAGS = %w[&lt;%= &lt;%# &lt;%- &lt;%].freeze
# locate caret (Allan's code)
line = ENV['TM_LINE_NUMBER'].to_i - ENV['TM_INPUT_START_LINE'].to_i
col = ENV['TM_LINE_INDEX'].to_i
if ENV['TM_LINE_NUMBER'].to_i == ENV['TM_INPUT_START_LINE'].to_i
col -= ENV['TM_INPUT_START_LINE_INDEX'].to_i
end
# read input
input = $stdin.read
# snippetize output
lines = RUBY_VERSION &lt; "1.9" ? input.to_a : input.lines.to_a
lines[line] = e_sn(lines[line][0...col]) + "${0}" + e_sn(lines[line][col..-1])
enum = RUBY_VERSION &lt; "1.9" ? lines.enum_with_index :
lines.each.with_index
output = enum.inject(String.new) do |out, (l, i)|
i == line ? out + l : out + e_sn(l)
end
# swap ERb tags
result = output.sub(/\A&lt;%[-#=]?/) { |match| TAGS[TAGS.index(match) - 1] }
if result[2] == ?-
result.sub!(/%&gt;\Z/, "-%&gt;")
else
result.sub!(/-%&gt;\Z/, "%&gt;")
end
print result</string>
<key>disableOutputAutoIndent</key>
<true/>
<key>fallbackInput</key>
<string>scope</string>
<key>input</key>
<string>selection</string>
<key>keyEquivalent</key>
<string>^&gt;</string>
<key>name</key>
<string>Toggle ERb Tags</string>
<key>output</key>
<string>insertAsSnippet</string>
<key>scope</key>
<string>source.ruby.embedded, source.ruby.rails.embedded, comment.block.erb, meta.erb</string>
<key>uuid</key>
<string>835FAAC6-5431-436C-998B-241F7226B99B</string>
</dict>
</plist>
Jump to Line
Something went wrong with that request. Please try again.