[Streamlined][876] patched template query to handle HAML extensions

0 views
Skip to first unread message

svn-str...@thinkrelevance.com

unread,
Jul 16, 2008, 9:37:15 AM7/16/08
to streamli...@googlegroups.com
Revision
876
Author
matthew
Date
2008-07-16 09:37:15 -0400 (Wed, 16 Jul 2008)

Log Message

patched template query to handle HAML extensions

Modified Paths

Added Paths

Diff

Modified: edge/streamlined/CHANGELOG (875 => 876)


--- edge/streamlined/CHANGELOG	2008-06-24 01:05:39 UTC (rev 875)
+++ edge/streamlined/CHANGELOG	2008-07-16 13:37:15 UTC (rev 876)
@@ -1,3 +1,5 @@
+07/16/08 - patched template query to handle HAML extensions [Matthew Bass]
+
 06/23/08 - added Sandro's patch for help text below edit fields [Matthew Bass]
 
 06/16/08 - fixed partial rendering calls that had been missed during RC3 refactoring [Matthew Bass]

Added: edge/streamlined/faux_rails_root/app/views/templates/haml_template.html.haml ( => )



Modified: edge/streamlined/lib/streamlined/render_methods.rb
===================================================================
--- edge/streamlined/lib/streamlined/render_methods.rb	2008-06-24 01:05:39 UTC (rev 875)
+++ edge/streamlined/lib/streamlined/render_methods.rb	2008-07-16 13:37:15 UTC (rev 876)
@@ -45,11 +45,15 @@
   
   # Returns true if the given template exists under <tt>app/views</tt>.
   # The template name can optionally include an extension.  If an extension
-  # is not provided, <tt>rhtml</tt> will be used by default.
+  # is not provided, <tt>rhtml</tt> and <tt>.html.haml</tt> will be used by default.
   def specific_template_exists?(template)
     template, extension = template.split('.')
     path = File.join(RAILS_ROOT, "app/views", template)
-    File.exist?("#{path}.#{extension || 'rhtml'}")
+    if extension.blank?
+      File.exist?("#{path}.rhtml") || File.exist?("#{path}.html.haml")
+    else
+      File.exist?("#{path}.#{extension}")
+    end
   end
   
   def convert_default_options(options)

Modified: edge/streamlined/test/unit/streamlined/render_methods_test.rb (875 => 876)


--- edge/streamlined/test/unit/streamlined/render_methods_test.rb	2008-06-24 01:05:39 UTC (rev 875)
+++ edge/streamlined/test/unit/streamlined/render_methods_test.rb	2008-07-16 13:37:15 UTC (rev 876)
@@ -6,6 +6,7 @@
   
   it "specific template exists?" do
     assert specific_template_exists?("templates/template")
+    assert specific_template_exists?("templates/haml_template")
     assert specific_template_exists?("templates/template.rhtml")
     assert specific_template_exists?("templates/template.rxml")
     assert !specific_template_exists?("templates/template.rpdf")
Reply all
Reply to author
Forward
0 new messages