]> git.openstreetmap.org Git - rails.git/commitdiff
Simplify partial rendering when the partial is named after the model
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 26 Jun 2019 12:13:09 +0000 (14:13 +0200)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 26 Jun 2019 12:13:09 +0000 (14:13 +0200)
17 files changed:
app/views/api/notes/index.gpx.builder
app/views/api/notes/index.json.jsonify
app/views/api/notes/index.rss.builder
app/views/api/notes/index.xml.builder
app/views/api/notes/show.gpx.builder
app/views/api/notes/show.json.jsonify
app/views/api/notes/show.rss.builder
app/views/api/notes/show.xml.builder
app/views/api/users/index.builder
app/views/api/users/show.builder
app/views/diary_entries/_diary_index_entry.html.erb [deleted file]
app/views/diary_entries/index.html.erb
app/views/diary_entries/show.html.erb
app/views/redactions/_redactions.html.erb [deleted file]
app/views/redactions/index.html.erb
app/views/traces/index.html.erb
app/views/users/index.html.erb

index 58da357da5f6daa688ed27de65f333c2c83b9858..d737752bf2cbc3eacf2d9531e858ab34e00155d0 100644 (file)
@@ -5,5 +5,5 @@ xml.gpx("version" => "1.1",
         "xmlns" => "http://www.topografix.com/GPX/1/1",
         "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
         "xsi:schemaLocation" => "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd") do
-  xml << (render(:partial => "note", :collection => @notes) || "")
+  xml << (render(@notes) || "")
 end
index cb75d41c4093d477d9c75367277aea2f8708abe7..bfc8ffcf854f3ed87c9569d05168462c8d52a725 100644 (file)
@@ -1,5 +1,5 @@
 json.type "FeatureCollection"
 
 json.features(@notes) do |note|
-  json.ingest! render(:partial => "note", :object => note)
+  json.ingest! render(note)
 end
index 96ba4b73412cb5ddc3bd496ce01b442607150d0c..95ea0b3b11394ca7a2b76b8b8dc6776ed19c7b14 100644 (file)
@@ -9,6 +9,6 @@ xml.rss("version" => "2.0",
     xml.description t("api.notes.rss.description_area", :min_lat => @min_lat, :min_lon => @min_lon, :max_lat => @max_lat, :max_lon => @max_lon)
     xml.link url_for(:controller => "/site", :action => "index", :only_path => false)
 
-    xml << (render(:partial => "note", :collection => @notes) || "")
+    xml << (render(@notes) || "")
   end
 end
index 286b1e1ccecd0b8513e77d41bc442aff826e21a1..ebb026e651396a5d8263e1a824feccbbe5023c13 100644 (file)
@@ -1,5 +1,5 @@
 xml.instruct!
 
 xml.osm(OSM::API.new.xml_root_attributes) do |osm|
-  osm << (render(:partial => "note", :collection => @notes) || "")
+  osm << (render(@notes) || "")
 end
index f87ff4dd947ba2f8f323287e6a9916cbe04644d0..750d01f562a4265e2a08dd934913b629e12275cd 100644 (file)
@@ -5,5 +5,5 @@ xml.gpx("version" => "1.1",
         "xmlns" => "http://www.topografix.com/GPX/1/1",
         "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
         "xsi:schemaLocation" => "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd") do
-  xml << render(:partial => "note", :object => @note)
+  xml << render(@note)
 end
index 3e5685fc0089e42a9891ab4f79e2c57fce7dbd9e..10d127291fcf5ef57eb167827f9fd1931a8cd027 100644 (file)
@@ -1 +1 @@
-json.ingest! render(:partial => "note", :object => @note)
+json.ingest! render(@note)
index 61ee0857a456562052e1186f75d53ed10e81f8df..d739ea6d998cc778862d8a7003550c152680b24a 100644 (file)
@@ -8,6 +8,6 @@ xml.rss("version" => "2.0",
     xml.description t("api.notes.rss.description_item", :id => @note.id)
     xml.link url_for(:controller => "/site", :action => "index", :only_path => false)
 
-    xml << render(:partial => "note", :object => @note)
+    xml << render(@note)
   end
 end
index 51b3daebd330db43c1cae2036a4efcff42cf2781..bb87fe76298ccb57efa6c6685b5a003cc59902b0 100644 (file)
@@ -1,5 +1,5 @@
 xml.instruct!
 
 xml.osm(OSM::API.new.xml_root_attributes) do |osm|
-  osm << render(:partial => "note", :object => @note)
+  osm << render(@note)
 end
index 68d629099f45177b13242a24d8bdb2cd9a1cd7fd..60fcfa898efbe8aa2068d9b0dbef2f9d52cae4c5 100644 (file)
@@ -1,4 +1,4 @@
 xml.instruct! :xml, :version => "1.0"
 xml.osm(OSM::API.new.xml_root_attributes) do |osm|
-  osm << render(:partial => "user", :collection => @users)
+  osm << render(@users)
 end
index dd5e9368920c936931fd022c3a98eef115b34976..96bfdd3fa9d0007313952c29b435becdb0fb4465 100644 (file)
@@ -1,4 +1,4 @@
 xml.instruct! :xml, :version => "1.0"
 xml.osm(OSM::API.new.xml_root_attributes) do |osm|
-  osm << render(:partial => "user", :object => @user)
+  osm << render(@user)
 end
diff --git a/app/views/diary_entries/_diary_index_entry.html.erb b/app/views/diary_entries/_diary_index_entry.html.erb
deleted file mode 100644 (file)
index 3d6df4e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-<%= render :partial => "diary_entry", :object => diary_index_entry %>
index 4610e5fd7403bdc45ce3598949fb9d9a958e8a75..acf9ac17c7f558a443bd0bde51f58227ead71372 100644 (file)
 <% else %>
   <h4><%= t ".recent_entries" %></h4>
 
-  <% if @user %>
-    <%= render :partial => "diary_entry", :collection => @entries %>
-  <% else %>
-    <%= render :partial => "diary_index_entry", :collection => @entries %>
-  <% end %>
+  <%= render @entries %>
 
   <div class="pagination">
     <% if @entries.size < @page_size -%>
index cc761b15d3b03829997cd75a92d14a8238d804ae..1cc1e1c5363212c303fd8eb6aefdb4c51d1f0b92 100644 (file)
@@ -6,7 +6,7 @@
   </div>
 <% end %>
 
-<%= render :partial => "diary_entry", :object => @entry %>
+<%= render @entry %>
 
 <a id="comments"></a>
 <div class='comments'>
diff --git a/app/views/redactions/_redactions.html.erb b/app/views/redactions/_redactions.html.erb
deleted file mode 100644 (file)
index 225e256..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<ul id="redaction_list">
-  <%= render :partial => "redaction", :collection => @redactions %>
-</ul>
index e3388fafa006b97ce74e1916d37f877ef5b89531..b6b6ef46e063e8f358eac3c64dc6ad8a440a918f 100644 (file)
@@ -4,7 +4,9 @@
 <% end %>
 
 <% unless @redactions.empty? %>
-  <%= render :partial => "redactions" %>
+  <ul id="redaction_list">
+    <%= render @redactions %>
+  </ul>
 <% else %>
   <p><%= t ".empty" %></p>
 <% end %>
index 9db246bd45149cd67180ccfdcf4de801ca023a9a..da40f5a4d64a16133f15b6083f9711c886ecc7a2 100644 (file)
@@ -33,7 +33,7 @@
       </tr>
     </thead>
     <tbody>
-      <%= render :partial => "trace", :collection => @traces unless @traces.nil? %>
+      <%= render @traces unless @traces.nil? %>
     </tbody>
   </table>
 
index ffaceeff012d8a00c0fa6313094451ca2a8b8b1a..f1ef5b5380f4460e84b31676b97a3b444c740bf6 100644 (file)
@@ -30,7 +30,7 @@
           <%= check_box_tag "user_all", "1", false %>
         </td>
       </tr>
-      <%= render :partial => "user", :collection => @users %>
+      <%= render @users %>
     </table>
 
     <div id="user_list_actions buttons">