Sha256: d82280790fa713834430c60d7b0b94b48ce4db466e5940699ebed898a0631600
Contents?: true
Size: 888 Bytes
Versions: 58
Compression:
Stored size: 888 Bytes
Contents
module Para module Markup class ResourceTree < Para::Markup::Component def tree_list(resources, options = {}, &block) options[:class] ||= '' options[:class] << ' tree-list' content_tag(:ul, options) do resources.each do |resource| block.call(resource) end end end def tree_node(resource: nil, label: nil, children: [], **options, &block) options[:class] ||= '' options[:class] << ' node' content_tag(:li, options) do node_row(resource, label) + node_children(children, &block) end end def node_row(resource, label) content_tag(:div, class: 'node-row') do label end end def node_children(children, &block) tree_list(children, &block) if children.length > 0 end end end end
Version data entries
58 entries across 58 versions & 1 rubygems