<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -19,16 +19,17 @@ end
 
 # If text is selected, create a partial out of it
 if TextMate.selected_text
+  ext = &quot;.html.#{current_file.extension}&quot;
   partial_name = TextMate::UI.request_string(
     :title =&gt; &quot;Create a partial from the selected text&quot;, 
     :default =&gt; &quot;partial&quot;,
-    :prompt =&gt; &quot;Name of the new partial: (omit the _ and .html.erb)&quot;,
+    :prompt =&gt; &quot;Name of the new partial: (omit the _ and #{ext})&quot;,
     :button1 =&gt; 'Create'
   )
 
   if partial_name
     path = current_file.dirname
-    partial = File.join(path, &quot;_#{partial_name}.html.erb&quot;)
+    partial = File.join(path, &quot;_#{partial_name}#{ext}&quot;)
 
     # Create the partial file
     if File.exist?(partial)
@@ -41,12 +42,21 @@ if TextMate.selected_text
         TextMate.exit_discard
       end
     end
-
-    file = File.open(partial, &quot;w&quot;) { |f| f.write(TextMate.selected_text) }
+    
+    # determine and strip identing of the partial
+    selected_text = TextMate.selected_text + &quot;&quot; # somehow .clone did not work
+    identing = selected_text.split(&quot;\n&quot;).first.to_s.match(/^(\s+)/) ? $1 : &quot;&quot;
+    selected_text.gsub!(/^#{identing}/, &quot;&quot;)
+    
+    file = File.open(partial, &quot;w&quot;) { |f| f.write(selected_text) }
     TextMate.rescan_project
 
     # Return the new render :partial line
-    print &quot;&lt;%= render :partial =&gt; '#{partial_name}' %&gt;\n&quot;
+    if current_file.extension == &quot;haml&quot;
+      print &quot;#{identing}!= render :partial =&gt; '#{partial_name}'\n&quot;
+    else
+      print &quot;#{identing}&lt;%= render :partial =&gt; '#{partial_name}' %&gt;\n&quot;
+    end
   else
     TextMate.exit_discard
   end</diff>
      <filename>Support/bin/create_partial_from_selection.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>4b12999462cad0db567019a3846395888002af94</id>
    </parent>
  </parents>
  <author>
    <name>Tobias Schwab</name>
    <email>tobstarr@gmail.com</email>
  </author>
  <url>http://github.com/drnic/ruby-on-rails-tmbundle/commit/2f096485e99f3610da1fbe0573a1f94ce747a57c</url>
  <id>2f096485e99f3610da1fbe0573a1f94ce747a57c</id>
  <committed-date>2009-09-15T02:04:50-07:00</committed-date>
  <authored-date>2009-09-15T02:04:50-07:00</authored-date>
  <message>create_partial_from_selection: use same extension as template for partial (e.g. .haml), keep identing for render line, strip prefix identing in partial</message>
  <tree>34c3183a4b023a597ad9b57933fca809a1fe3297</tree>
  <committer>
    <name>Tobias Schwab</name>
    <email>tobstarr@gmail.com</email>
  </committer>
</commit>
