Sha256: b8f1ff2ea15d906f7d97bde0b3d6c85d7a3f330b87f1fa8be590c20e268f921d
Contents?: true
Size: 943 Bytes
Versions: 1
Compression:
Stored size: 943 Bytes
Contents
# Hash unless {}.respond_to?(:tag) class Hash def tag node_name, inner_html=nil, &block HtmlTag::Inbound.new.tag(node_name, inner_html, self, &block).join('') end end end # String unless ''.respond_to?(:tag) class String def tag node_name, opts = nil, &block HtmlTag::Inbound.new.tag(node_name, self, opts, &block).join('') end end end # HtmlTag do ... module HtmlTag class Proxy def initialize scope = nil @pointer = HtmlTag::Inbound.new scope end def method_missing name, *args, &block @pointer .send(name, *args, &block) .join('') end end end def HtmlTag *args, &block args[0] ||= :div if args[0].class == Hash args[1] = args[0] args[0] = :div end if block # HtmlTag(:ul) { li ... } out = HtmlTag::Inbound.new self out.send(*args, &block) out.render else # HtmlTag._foo 123 HtmlTag::Proxy.new self end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
html-tag-3.0.3 | ./lib/html-tag/globals.rb |