Skip to content

Commit 017dea5

Browse files
authored
Merge pull request #1434 from projectblacklight/deprecate_render_index_field_value
Deprecate render_(index|show)_field_value and use the presenter
2 parents 24c5241 + c08a263 commit 017dea5

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

app/helpers/blacklight/blacklight_helper_behavior.rb

+7-2
Original file line numberDiff line numberDiff line change
@@ -160,18 +160,21 @@ def render_index_field_label *args
160160
# @param [String] field
161161
# @param [Hash] opts
162162
# @options opts [String] :value
163-
# TODO: deprecate and use render_field_value
163+
# @deprecated use IndexPresenter#field_value
164164
def render_index_field_value *args
165165
render_field_value(*args)
166166
end
167+
deprecation_deprecate render_index_field_value: 'replaced by IndexPresenter#field_value'
167168

169+
# @deprecated use IndexPresenter#field_value
168170
def render_field_value(*args)
169171
options = args.extract_options!
170172
document = args.shift || options[:document]
171173

172174
field = args.shift || options[:field]
173175
presenter(document).field_value field, options.except(:document, :field)
174176
end
177+
deprecation_deprecate render_field_value: 'replaced by IndexPresenter#field_value'
175178

176179
##
177180
# Render the show field label for a document
@@ -218,10 +221,12 @@ def render_document_show_field_label *args
218221
# @param [String] field
219222
# @param [Hash] opts
220223
# @options opts [String] :value
221-
# TODO: deprecate and use render_field_value
224+
# @deprecated use ShowPresenter#field_value
222225
def render_document_show_field_value *args
223226
render_field_value(*args)
224227
end
228+
deprecation_deprecate render_document_show_field_value: 'replaced by ShowPresenter#field_value'
229+
225230

226231
##
227232
# Get the value of the document's "title" field, or a placeholder

app/views/catalog/_index_default.html.erb

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
<% doc_presenter = index_presenter(document) %>
12
<%# default partial to display solr document fields in catalog index view -%>
23
<dl class="document-metadata dl-horizontal dl-invert">
34

45
<% index_fields(document).each do |field_name, field| -%>
56
<% if should_render_index_field? document, field %>
67
<dt class="blacklight-<%= field_name.parameterize %>"><%= render_index_field_label document, field: field_name %></dt>
7-
<dd class="blacklight-<%= field_name.parameterize %>"><%= render_index_field_value document, field: field_name %></dd>
8+
<dd class="blacklight-<%= field_name.parameterize %>"><%= doc_presenter.field_value field_name %></dd>
89
<% end -%>
910
<% end -%>
1011

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
<% doc_presenter = show_presenter(document) %>
12
<%# default partial to display solr document fields in catalog show view -%>
23
<dl class="dl-horizontal dl-invert">
34
<% document_show_fields(document).each do |field_name, field| -%>
45
<% if should_render_show_field? document, field %>
56
<dt class="blacklight-<%= field_name.parameterize %>"><%= render_document_show_field_label document, field: field_name %></dt>
6-
<dd class="blacklight-<%= field_name.parameterize %>"><%= render_document_show_field_value document, field: field_name %></dd>
7+
<dd class="blacklight-<%= field_name.parameterize %>"><%= doc_presenter.field_value field_name %></dd>
78
<% end -%>
89
<% end -%>
910
</dl>

spec/helpers/blacklight_helper_spec.rb

+2
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ def current_search_session
165165
describe "#render_index_field_value" do
166166
let(:presenter) { double }
167167
before do
168+
allow(Deprecation).to receive(:warn)
168169
allow(helper).to receive(:presenter).with(doc).and_return(presenter)
169170
end
170171

@@ -191,6 +192,7 @@ def current_search_session
191192
let(:presenter) { double }
192193
before do
193194
allow(helper).to receive(:presenter).with(doc).and_return(presenter)
195+
allow(Deprecation).to receive(:warn)
194196
end
195197

196198
let(:doc) { double }

0 commit comments

Comments
 (0)