require "tree_html/version" module TreeHtml NO_DATA_IN_A = {}.freeze NO_CHECKBOX = "".freeze BLANK = ''.freeze NO_CUSTOM_JS = [].freeze Css = File.read File.expand_path('../tree_html/tree_html.css', __FILE__) Js = Dir.glob("#{File.expand_path(__dir__)}/tree_html/*.js").map{|f| File.read f }.join(';') def tree_html "" end def tree_html_full ""\ ""\ ""\ ""\ "#{custom_js head_js_for_tree_html}"\ ""\ ""\ "#{tree_html}"\ ""\ "#{custom_js body_js_for_tree_html}"\ ""\ "" end protected def li_for_tree_html "
  • #{checkbox}#{label_for_tree_html}#{sub_ul}
  • " end def data_for_tree_html NO_DATA_IN_A end def css_for_tree_html BLANK end def head_js_for_tree_html NO_CUSTOM_JS end def body_js_for_tree_html NO_CUSTOM_JS end private def sub_ul if children_for_tree_html.empty? BLANK else "" end end def checkbox if children_for_tree_html.empty? NO_CHECKBOX else "" end end def data_in_a data_for_tree_html.map{ |k, v| "data-#{k}='#{v}'" }.join(" ") end def custom_js scripts scripts.map do |s| src = s[:src] ? "src='#{s[:src]}'" : BLANK "" end.join end end