5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-07-04 16:05:44 +00:00

traer los valores de anidaciones recursivas

This commit is contained in:
f 2018-07-24 16:28:58 -03:00
parent 96597db1d6
commit 02733728a3
No known key found for this signature in database
GPG key ID: F3FDAB97B5F9F7E7
3 changed files with 5 additions and 2 deletions

View file

@ -292,11 +292,13 @@ class Post
# Si hay un subatributo, tenemos que averiguar todos los
# valores dentro de el
# TODO volver elegante!
# TODO volver recursivo!
elsif subattr
post.site.everything_of(attr, lang: collection)
.compact
.map { |sv| sv[subattr] }
.flatten
.compact
.uniq
else
post.site.everything_of(attr, lang: collection).compact

View file

@ -1,5 +1,5 @@
- value = [] if value.nil?
- values = template.values.empty? ? value : template.values
- values = template.values.empty? ? [value].flatten : template.values
= select_tag field_name_for_post_as_string(name),
options_for_select(values, value),
{ class: 'form-control select2',

View file

@ -9,7 +9,7 @@
-# todos los que sean necesarios si estamos editando un post.
-# Obtenemos todos los valores. Puede ser un Hash o un Array
-# Creamos un array con un elemento solo para poder tener acceso a :each
- groups = @post.get_front_matter(template.key)
- groups = @post.get_front_matter(name)
-# TODO volver a revisar cuando get_front_matter() tenga valores por defecto
- groups = [{}] unless groups
- if groups.is_a? Hash
@ -45,6 +45,7 @@
-# Si el campo es un array, groups es un array de hashes
-# y group un hash. De lo contrarios, groups va a ser un
-# Hash
-# TODO cambiar por get_front_matter
- value = (template.array? || template.nested?) ? group[nf.key] : groups[nf.key]
= render 'posts/template_field/nested',
template: nf,