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

Version Path
para-0.7.3.p5 lib/para/markup/resources_tree.rb
para-0.7.3.p4 lib/para/markup/resources_tree.rb
para-0.7.3.p3 lib/para/markup/resources_tree.rb
para-0.7.3.p2 lib/para/markup/resources_tree.rb
para-0.7.3.p1 lib/para/markup/resources_tree.rb
para-0.7.3 lib/para/markup/resources_tree.rb
para-0.7.2 lib/para/markup/resources_tree.rb
para-0.7.1 lib/para/markup/resources_tree.rb
para-0.7.0 lib/para/markup/resources_tree.rb
para-0.6.9 lib/para/markup/resources_tree.rb
para-0.6.8 lib/para/markup/resources_tree.rb
para-0.6.7 lib/para/markup/resources_tree.rb
para-0.6.3 lib/para/markup/resources_tree.rb
para-0.6.2 lib/para/markup/resources_tree.rb
para-0.5.4 lib/para/markup/resources_tree.rb
para-0.5.3 lib/para/markup/resources_tree.rb
para-0.5.1 lib/para/markup/resources_tree.rb
para-0.5.0 lib/para/markup/resources_tree.rb