Skip to content

Instantly share code, notes, and snippets.

@jugyo
Created March 11, 2011 05:02
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jugyo/865475 to your computer and use it in GitHub Desktop.
Save jugyo/865475 to your computer and use it in GitHub Desktop.
TextMate command to convert slim to html
#!/usr/bin/env ruby
# Input: Selected Text or Nothing
# Output: Replace Selected Text
require 'tempfile'
def unindent(text)
lines = text.split(/\n/)
level = lines.map{|l| l[/^\s*/].size}.min
[lines.map{|l| l[level..-1]}.join("\n"), level]
end
text, level = unindent(STDIN.read)
Tempfile.open('haml2html') do |t|
t << text
t.flush
output = `#{File.join(ENV['TM_GEM_BIN'], 'slimrb')} -p #{t.path}`
puts output.split("\n").map{|l| ' ' * level + l}.join("\n")
end
@LeoBogod22
Copy link

  • single_content_for :action do
    ' commented on
    =' whose?(a.owner, a.trackable)
    = link_to_trackable a.trackable, a.trackable_type

= p[:comment]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment