module Ezframe::Ht
Public Class Methods
icon(arg)
click to toggle source
materialize用のiconメソッド 引数が文字列だったら、それをname属性とする
# File lib/ezframe/ht.rb, line 78 def icon(arg) if arg.is_a?(Hash) h = arg.clone h[:tag] = "icon" return wrap_tag(h) elsif arg.is_a?(String) return { tag: "icon", wrap: true, name: arg } end end
multi_div(class_a, child)
click to toggle source
# File lib/ezframe/ht.rb, line 97 def multi_div(class_a, child) class_a.reverse.each do |klass| child = Ht.div(class: klass, child: child) end return child end
search(ht_h, opts)
click to toggle source
# File lib/ezframe/ht.rb, line 104 def search(ht_h, opts) @found ||= [] if ht_h.is_a?(Hash) if opts[:tag] && ht_h[:tag] && ht_h[:tag] == opts[:tag] @found.push(ht_h) end if ht_h[:child] search(ht_h[:child], opts) end elsif ht_h.is_a?(Array) ht_h.map { |h| search(h, opts) } end return @found end
single_tag(ht_h = {})
click to toggle source
# File lib/ezframe/ht.rb, line 26 def single_tag(ht_h = {}) ht_h[:tag] ||= __callee__.to_s raise "no tag" if ht_h[:tag] == "wrap_tag" raise "has child: #{ht_h.inspect}" if ht_h[:child] return ht_h end
wrap_tag(ht_h = {})
click to toggle source
メソッド名の名前のタグのhthashを生成
# File lib/ezframe/ht.rb, line 6 def wrap_tag(ht_h = {}) return nil unless ht_h if ht_h.is_a?(String) || ht_h.is_a?(Array) h = { child: ht_h } elsif ht_h.is_a?(Hash) if ht_h[:tag] && !__callee__.to_s.index("wrap_tag") h = { child: ht_h } else h = ht_h.dup end else EzLog.info("[WARN] wrap_tag: unknown type: #{ht_h.inspect}") return nil end h[:tag] ||= __callee__.to_s h[:wrap] = true raise "no tag" if h[:tag] == "wrap_tag" return h end