Skip to content

Commit

Permalink
Remove usage of jinja2 map function.
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-sanders committed Nov 2, 2017
1 parent 13de923 commit ba9b9ad
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
5 changes: 5 additions & 0 deletions lib/html/static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ var FileLoader = ( function () {
* number. */
num = parseInt(num);

if (previous_search) {
loadFile("", num)
return
}

// Remove previously highlighted lines.
var highlights = $($('#filecode')[0]).find('span.highlight');
for (high=0; high<highlights.length; high++) {
Expand Down
20 changes: 10 additions & 10 deletions lib/html/template/rose-bush/view-search.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@
{% else -%}
<div class="col-md-11">
{% endif -%}
{% if not file_content -%}
{% set lines = lines | map(
'replace', 'DEBUG', '<span class="nocode text-muted">DEBUG</span>') | map(
'replace', 'INFO', '<span class="nocode text-info">INFO</span>') | map(
'replace', 'ERROR', '<span class="nocode text-dander">ERROR</span>') | map(
'replace', 'CRITICAL', '<span class="nocode text-dander">CRITICAL</span>') | map(
'replace', 'WARNING', '<span class="nocode text-warning">WARNING</span>') -%}
{% endif -%}
<pre id="filecode" {% if file_content %}class="prettyprint lang-{{file_content}}"{% endif -%}>
{% for line in lines -%}
{% for part in line -%}
{% if loop.index % 2 == 1 -%}{{part}}{% else
-%}<span class="highlight">{{part}}</span>{% endif -%}
{% if not file_content -%}
{% set part = part | replace(
'DEBUG', '<span class="nocode text-muted">DEBUG</span>') | replace(
'INFO', '<span class="nocode text-info">INFO</span>') | replace(
'ERROR', '<span class="nocode text-dander">ERROR</span>') | replace(
'CRITICAL', '<span class="nocode text-dander">CRITICAL</span>') | replace(
'WARNING', '<span class="nocode text-warning">WARNING</span>') -%}
{% endif -%}
{% if loop.index % 2 == 1 -%}{{part}}{% else
-%}<span class="highlight">{{part}}</span>{%
endif -%}
{% endfor -%}
{{ "" }}
{% endfor -%}
Expand Down
16 changes: 8 additions & 8 deletions lib/html/template/rose-bush/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ <h1>{{path}}</h1>
</pre>
</div>
<div class="col-md-11">
{% if not file_content -%}
{% set lines = lines | map(
'replace', 'DEBUG', '<span class="nocode text-muted">DEBUG</span>') | map(
'replace', 'INFO', '<span class="nocode text-info">INFO</span>') | map(
'replace', 'ERROR', '<span class="nocode text-dander">ERROR</span>') | map(
'replace', 'CRITICAL', '<span class="nocode text-dander">CRITICAL</span>') | map(
'replace', 'WARNING', '<span class="nocode text-warning">WARNING</span>') -%}
{% endif -%}
<pre id="filecode"{% if file_content %} class="prettyprint lang-{{file_content}}"{% endif %}>
{% for line in lines -%}
{% if not file_content -%}
{% set line = line | replace(
'DEBUG', '<span class="nocode text-muted">DEBUG</span>') | replace(
'INFO', '<span class="nocode text-info">INFO</span>') | replace(
'ERROR', '<span class="nocode text-dander">ERROR</span>') | replace(
'CRITICAL', '<span class="nocode text-dander">CRITICAL</span>') | replace(
'WARNING', '<span class="nocode text-warning">WARNING</span>') -%}
{% endif -%}
{% if mode == "tags" -%}
{{line}}
{% else -%}
Expand Down

0 comments on commit ba9b9ad

Please sign in to comment.