Skip to content

Instantly share code, notes, and snippets.

@jeresig
Created January 15, 2013 21:01
Show Gist options
  • Save jeresig/4542023 to your computer and use it in GitHub Desktop.
Save jeresig/4542023 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
$: << ENV['TM_SUPPORT_PATH'] + '/lib'
require 'escape'
def esc(str)
e_sn(str).gsub(/\}/, '\\}').gsub(/"/, '\\\\"')
end
s = STDIN.read
if ENV.has_key? 'TM_SELECTED_TEXT'
print "${1:{{ __(\"#{esc s}\") \\}\\}}"
else
print "{{ __(\"#{e_sn s}\") }}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment