Skip to content

Commit

Permalink
Extract result to separate view
Browse files Browse the repository at this point in the history
We're about to do a lot of fiddling around with results, to keep the
code nice and clean, extract `result` to a single template.
  • Loading branch information
Alice Bartlett committed Apr 9, 2015
1 parent f9c24d7 commit 318731b
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 85 deletions.
85 changes: 85 additions & 0 deletions app/views/search/_result.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<li{{#external}} class="external"{{/external}}>
<h3><a href="{{link}}" {{#external}}rel="external"{{/external}}>{{title}}</a></h3>

{{#debug_score}}
<p class="debug-link">
{{link}}
</p>
<p class="debug-info">
<span>Score: {{es_score}}</span>
<span>Format: {{#government}}government{{/government}} {{format}}</span>
</p>
{{/debug_score}}

{{#external}}
<p class="meta">
<span class="visuallyhidden">Part of </span>
<span class="url">{{ display_link }}</span>
</p>
{{/external}}

{{#section}}
<p class="meta crumbtrail">
<span class="visuallyhidden">Part of </span>
<span class="section">{{formatted_section_name}}</span>
{{#formatted_subsection_name}}
<span class="visuallyhidden">, </span>
<span class="subsection">{{ formatted_subsection_name }}</span>
{{/formatted_subsection_name}}
{{#formatted_subsubsection_name}}
<span class="visuallyhidden">, </span>
<span class="subsubsection">{{ formatted_subsubsection_name }}</span>
{{/formatted_subsubsection_name}}
</p>
{{/section}}

{{#metadata_any?}}
<ul class="attributes">
{{#metadata}}
<li> {{{.}}} </li>
{{/metadata}}
</ul>
{{/metadata_any?}}

{{#historic?}}
{{#government_name}}
<p class="historic">
First published during the {{government_name}}
</p>
{{/government_name}}
{{/historic?}}

<p>{{description}}</p>

{{#sections_present?}}
<ul class="sections">
{{#sections}}
<li><a href="{{link}}#{{hash}}">{{title}}</a></li>
{{/sections}}
</ul>
{{/sections_present?}}

{{#examples_present?}}
<ul class="examples">
{{#examples}}
<li>
<h4><a href="{{link}}">{{title}}</a></h4>
<p>{{description}}</p>
</li>
{{/examples}}

{{#suggested_filter_present?}}
<li>
<h4 class="see-all"><a href="{{suggested_filter_link}}">{{suggested_filter_title}}</a><h4>
</li>
{{/suggested_filter_present?}}
</ul>
{{/examples_present?}}

{{^examples_present?}}
{{#suggested_filter_present?}}
<h4 class="see-all"><a href="{{suggested_filter_link}}">{{suggested_filter_title}}</a><h4>
{{/suggested_filter_present?}}
{{/examples_present?}}

</li>
86 changes: 1 addition & 85 deletions app/views/search/_results_list.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -12,91 +12,7 @@
{{#results_any?}}
<ol class="results-list{{#debug_score}} debug{{/debug_score}}" id="js-live-search-results" start="{{first_result_number}}">
{{#results}}
<li{{#external}} class="external"{{/external}}>
<h3><a href="{{link}}" {{#external}}rel="external"{{/external}}>{{title}}</a></h3>

{{#debug_score}}
<p class="debug-link">
{{link}}
</p>
<p class="debug-info">
<span>Score: {{es_score}}</span>
<span>Format: {{#government}}government{{/government}} {{format}}</span>
</p>
{{/debug_score}}

{{#external}}
<p class="meta">
<span class="visuallyhidden">Part of </span>
<span class="url">{{ display_link }}</span>
</p>
{{/external}}

{{#section}}
<p class="meta crumbtrail">
<span class="visuallyhidden">Part of </span>
<span class="section">{{formatted_section_name}}</span>
{{#formatted_subsection_name}}
<span class="visuallyhidden">, </span>
<span class="subsection">{{ formatted_subsection_name }}</span>
{{/formatted_subsection_name}}
{{#formatted_subsubsection_name}}
<span class="visuallyhidden">, </span>
<span class="subsubsection">{{ formatted_subsubsection_name }}</span>
{{/formatted_subsubsection_name}}
</p>
{{/section}}

{{#metadata_any?}}
<ul class="attributes">
{{#metadata}}
<li> {{{.}}} </li>
{{/metadata}}
</ul>
{{/metadata_any?}}

{{#historic?}}
{{#government_name}}
<p class="historic">
First published during the {{government_name}}
</p>
{{/government_name}}
{{/historic?}}

<p>{{description}}</p>

{{#sections_present?}}
<ul class="sections">
{{#sections}}
<li><a href="{{link}}#{{hash}}">{{title}}</a></li>
{{/sections}}
</ul>
{{/sections_present?}}

{{#examples_present?}}
<ul class="examples">
{{#examples}}
<li>
<h4><a href="{{link}}">{{title}}</a></h4>
<p>{{description}}</p>
</li>
{{/examples}}

{{#suggested_filter_present?}}
<li>
<h4 class="see-all"><a href="{{suggested_filter_link}}">{{suggested_filter_title}}</a><h4>
</li>
{{/suggested_filter_present?}}
</ul>
{{/examples_present?}}

{{^examples_present?}}
{{#suggested_filter_present?}}
<h4 class="see-all"><a href="{{suggested_filter_link}}">{{suggested_filter_title}}</a><h4>
{{/suggested_filter_present?}}
{{/examples_present?}}

</li>
{{>search/_result}}
{{/results}}
</ol>

Expand Down

0 comments on commit 318731b

Please sign in to comment.