convertir los indices numericos a integers

This commit is contained in:
f 2018-07-24 16:28:34 -03:00
parent 93076ac8bf
commit 96597db1d6
No known key found for this signature in database
GPG key ID: F3FDAB97B5F9F7E7

View file

@ -282,9 +282,15 @@ class Post
end
# Obtiene metadatos de forma recursiva
# TODO devolver un valor por defecto en base al template?
def get_front_matter(name)
if name.is_a? Array
# Convertir los indices numericos a integers
name = name.map { |i| i =~ /[0-9]+/ ? i.to_i : i }
else
# XXX retrocompatibilidad
name = name.to_s unless name.is_a? Array
name = name.to_s
end
@front_matter.dig(*name)
end