diff --git a/app/views/posts/show.haml b/app/views/posts/show.haml index 22b2430..b32b989 100644 --- a/app/views/posts/show.haml +++ b/app/views/posts/show.haml @@ -28,28 +28,56 @@ :markdown #{@post.content} - %table.table.table-condensed.table-striped + -# Representar los datos en una tabla: + -# Texto: tal cual en una celda + -# Array: píldoras + -# Array de Hashes: Tabla + -# Hash: Tabla + -# TODO DRY + %table.table.table-condensed.table-striped.table-responsive %tbody - - hashes = {} - @post.front_matter.each do |key, data| - - if data.is_a? Hash - - hashes[key] = data - - next %tr %th= t("posts.#{key}") %td - if data.is_a? Array - - data.each do |d| - %span.badge.badge-success= d + -# Un Array de Hashes + - if data.all? { |a| a.is_a? Hash } + %table + %thead + %tr + - data.first.keys.each do |k| + %th= k.humanize + %tbody + - data.each do |r| + %tr + - r.each do |_,v| + %td + - if v.is_a? Array + - v.each do |s| + %span.badge.badge-secondary= s + - else + = v + - else + - data.each do |d| + %span.badge.badge-secondary= d + - elsif data.is_a? Hash + %table + %thead + %tr + - data.keys.each do |k| + %th= k.humanize + %tbody + %tr + - data.each do |_, v| + %td= v - elsif data.respond_to? :content + -# Contenido del artículo :markdown #{data.content} - elsif data.respond_to? :strftime + -# Fecha = data.strftime('%F') - else + -# Texto = data - - hashes.each do |key, data| - - data.each do |k,d| - %tr - %th= t("posts.#{key}.#{k}") - %td= d