Skip to content
Snippets Groups Projects
Commit f97bc7dd authored by Arnaud Levy's avatar Arnaud Levy
Browse files

fix uninitialized blocks

parent e741ab73
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,7 @@ class Communication::Block::Template ...@@ -12,7 +12,7 @@ class Communication::Block::Template
protected protected
def data def data
block.data block.data || {}
end end
def university def university
......
...@@ -4,5 +4,6 @@ blocks: ...@@ -4,5 +4,6 @@ blocks:
- template: <%= block.template %> - template: <%= block.template %>
position: <%= block.position %> position: <%= block.position %>
data: data:
<%= render "admin/communication/blocks/templates/#{block.template}/static", block: block if block.data %><% end %> <%= render "admin/communication/blocks/templates/#{block.template}/static",
block: block if block.data && block.data.present? %><% end %>
<% end %> <% end %>
<h2><%= @block.data['title'] %></h2> <% if @block.data %>
<div class="row"> <h2><%= @block.data['title'] %></h2>
<% @block.data['elements'].each do |image| %> <div class="row">
<div class="col-xxl-2 col-xl-3 col-6"> <% @block.data['elements'].each do |image| %>
<article class="card"> <div class="col-xxl-2 col-xl-3 col-6">
<% unless image.dig('file', 'id').blank? %> <article class="card">
<% blob = ActiveStorage::Blob.find(image.dig('file', 'id')) %> <% unless image.dig('file', 'id').blank? %>
<%= kamifusen_tag blob, width: 500, class: 'img-fluid mb-2' %> <% blob = ActiveStorage::Blob.find(image.dig('file', 'id')) %>
<% end %> <%= kamifusen_tag blob, width: 500, class: 'img-fluid mb-2' %>
<div class="card-body"> <% end %>
<p class="mb-0"><%= image['alt'] %></p> <div class="card-body">
</div> <p class="mb-0"><%= image['alt'] %></p>
</article> </div>
</div> </article>
</div>
<% end %>
</div>
<% end %> <% end %>
</div>
<% if !block.data.nil? && !block.data.is_a?(String) && block.data.has_key?('elements') %>
title: > title: >
<%= prepare_text_for_static block.data['title'] %> <%= prepare_text_for_static block.data['title'] %>
images: images:
<% if block.data.has_key?('elements') %>
<% block.data['elements'].each do |image| <% block.data['elements'].each do |image|
file_id = nil file_id = nil
if image.has_key?('file') if image.has_key?('file')
......
...@@ -16,4 +16,4 @@ ...@@ -16,4 +16,4 @@
</div> </div>
<% end %> <% end %>
</div> </div>
<% end %> <% end if @block.data %>
<% if !block.data.nil? && !block.data.is_a?(String) && block.data.has_key?('elements') %> <% if block.data.has_key?('elements') %>
<% block.data['elements'].each do |element| %> <% block.data['elements'].each do |element| %>
- title: > - title: >
<%= prepare_text_for_static element['title'] %> <%= prepare_text_for_static element['title'] %>
......
...@@ -16,4 +16,4 @@ ...@@ -16,4 +16,4 @@
</div> </div>
<% end %> <% end %>
</div> </div>
<% end %> <% end if @block.data %>
<% if !block.data.nil? && !block.data.is_a?(String) && block.data.has_key?('elements') %> <% if block.data.has_key?('elements') %>
<% block.data['elements'].each do |element| %> <% block.data['elements'].each do |element| %>
- title: > - title: >
<%= element['title'] %> <%= element['title'] %>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment