Simplify partial rendering when the partial is named after the model

This commit is contained in:
Andy Allan 2019-06-26 14:13:09 +02:00
parent 5b4636d521
commit 3914050fcc
17 changed files with 17 additions and 23 deletions

View file

@ -5,5 +5,5 @@ xml.gpx("version" => "1.1",
"xmlns" => "http://www.topografix.com/GPX/1/1", "xmlns" => "http://www.topografix.com/GPX/1/1",
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", "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 "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 end

View file

@ -1,5 +1,5 @@
json.type "FeatureCollection" json.type "FeatureCollection"
json.features(@notes) do |note| json.features(@notes) do |note|
json.ingest! render(:partial => "note", :object => note) json.ingest! render(note)
end end

View 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.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.link url_for(:controller => "/site", :action => "index", :only_path => false)
xml << (render(:partial => "note", :collection => @notes) || "") xml << (render(@notes) || "")
end end
end end

View file

@ -1,5 +1,5 @@
xml.instruct! xml.instruct!
xml.osm(OSM::API.new.xml_root_attributes) do |osm| xml.osm(OSM::API.new.xml_root_attributes) do |osm|
osm << (render(:partial => "note", :collection => @notes) || "") osm << (render(@notes) || "")
end end

View file

@ -5,5 +5,5 @@ xml.gpx("version" => "1.1",
"xmlns" => "http://www.topografix.com/GPX/1/1", "xmlns" => "http://www.topografix.com/GPX/1/1",
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", "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 "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 end

View file

@ -1 +1 @@
json.ingest! render(:partial => "note", :object => @note) json.ingest! render(@note)

View file

@ -8,6 +8,6 @@ xml.rss("version" => "2.0",
xml.description t("api.notes.rss.description_item", :id => @note.id) xml.description t("api.notes.rss.description_item", :id => @note.id)
xml.link url_for(:controller => "/site", :action => "index", :only_path => false) xml.link url_for(:controller => "/site", :action => "index", :only_path => false)
xml << render(:partial => "note", :object => @note) xml << render(@note)
end end
end end

View file

@ -1,5 +1,5 @@
xml.instruct! xml.instruct!
xml.osm(OSM::API.new.xml_root_attributes) do |osm| xml.osm(OSM::API.new.xml_root_attributes) do |osm|
osm << render(:partial => "note", :object => @note) osm << render(@note)
end end

View file

@ -1,4 +1,4 @@
xml.instruct! :xml, :version => "1.0" xml.instruct! :xml, :version => "1.0"
xml.osm(OSM::API.new.xml_root_attributes) do |osm| xml.osm(OSM::API.new.xml_root_attributes) do |osm|
osm << render(:partial => "user", :collection => @users) osm << render(@users)
end end

View file

@ -1,4 +1,4 @@
xml.instruct! :xml, :version => "1.0" xml.instruct! :xml, :version => "1.0"
xml.osm(OSM::API.new.xml_root_attributes) do |osm| xml.osm(OSM::API.new.xml_root_attributes) do |osm|
osm << render(:partial => "user", :object => @user) osm << render(@user)
end end

View file

@ -1 +0,0 @@
<%= render :partial => "diary_entry", :object => diary_index_entry %>

View file

@ -32,11 +32,7 @@
<% else %> <% else %>
<h4><%= t ".recent_entries" %></h4> <h4><%= t ".recent_entries" %></h4>
<% if @user %> <%= render @entries %>
<%= render :partial => "diary_entry", :collection => @entries %>
<% else %>
<%= render :partial => "diary_index_entry", :collection => @entries %>
<% end %>
<div class="pagination"> <div class="pagination">
<% if @entries.size < @page_size -%> <% if @entries.size < @page_size -%>

View file

@ -6,7 +6,7 @@
</div> </div>
<% end %> <% end %>
<%= render :partial => "diary_entry", :object => @entry %> <%= render @entry %>
<a id="comments"></a> <a id="comments"></a>
<div class='comments'> <div class='comments'>

View file

@ -1,3 +0,0 @@
<ul id="redaction_list">
<%= render :partial => "redaction", :collection => @redactions %>
</ul>

View file

@ -4,7 +4,9 @@
<% end %> <% end %>
<% unless @redactions.empty? %> <% unless @redactions.empty? %>
<%= render :partial => "redactions" %> <ul id="redaction_list">
<%= render @redactions %>
</ul>
<% else %> <% else %>
<p><%= t ".empty" %></p> <p><%= t ".empty" %></p>
<% end %> <% end %>

View file

@ -33,7 +33,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<%= render :partial => "trace", :collection => @traces unless @traces.nil? %> <%= render @traces unless @traces.nil? %>
</tbody> </tbody>
</table> </table>

View file

@ -30,7 +30,7 @@
<%= check_box_tag "user_all", "1", false %> <%= check_box_tag "user_all", "1", false %>
</td> </td>
</tr> </tr>
<%= render :partial => "user", :collection => @users %> <%= render @users %>
</table> </table>
<div id="user_list_actions buttons"> <div id="user_list_actions buttons">