3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/attributarchy/helpers.rb', line 3
def build_attributarchy(name, data, level_index = 0)
output ||= ''
output = %{<div class="attributarchy">} if level_index == 0 current_level = attributarchy_configuration[name][level_index]
data.group_by(¤t_level).each_with_index do |(group_value, group_data), index|
output << %{<div class="#{current_level}-attributarchy">}
unless attributarchy_configuration[:without_rendering].has_key?(current_level)
output << (
render_to_string partial: "/#{current_level}", locals: {
group_data: group_data,
group_value: group_value,
group_level: level_index
}
)
end
if level_index < attributarchy_configuration[name].count - 1
output << build_attributarchy(name, group_data, level_index + 1)
end
output << '</div>'
end
output << '</div>' if level_index == 0 output.html_safe
end
|