Commit a99ad3d355f22907b38fad0a5b276e176c3901a7
1 parent
9ba21dd0
Exists in
master
and in
4 other branches
tree_heleper: concat html only if present. Avoid nil exception
Showing
1 changed file
with
9 additions
and
7 deletions
Show diff stats
app/helpers/tree_helper.rb
@@ -13,13 +13,15 @@ module TreeHelper | @@ -13,13 +13,15 @@ module TreeHelper | ||
13 | tree += render partial: 'tree/tree_item', collection: folders, locals: {type: 'folder'} if folders.present? | 13 | tree += render partial: 'tree/tree_item', collection: folders, locals: {type: 'folder'} if folders.present? |
14 | 14 | ||
15 | files.each do |f| | 15 | files.each do |f| |
16 | - if f.respond_to?(:url) | ||
17 | - # Object is a Submodule | ||
18 | - tree += render partial: 'tree/submodule_item', object: f | ||
19 | - else | ||
20 | - # Object is a Blob | ||
21 | - tree += render partial: 'tree/tree_item', object: f, locals: {type: 'file'} | ||
22 | - end | 16 | + html = if f.respond_to?(:url) |
17 | + # Object is a Submodule | ||
18 | + render partial: 'tree/submodule_item', object: f | ||
19 | + else | ||
20 | + # Object is a Blob | ||
21 | + render partial: 'tree/tree_item', object: f, locals: {type: 'file'} | ||
22 | + end | ||
23 | + | ||
24 | + tree += html if html.present? | ||
23 | end | 25 | end |
24 | 26 | ||
25 | tree.html_safe | 27 | tree.html_safe |