class Card::Bootstrap::TagMethod

support html tag generation

Public Class Methods

new(component, name, html_class, tag_opts={}) click to toggle source
# File lib/card/bootstrap/tag_method.rb, line 7
def initialize component, name, html_class, tag_opts={}, &tag_block
  @component = component
  @name = name
  @html_class = html_class
  @tag_opts = tag_opts
  @tag_block = tag_block
  @append = []
  @wrap = []
  @xm = Builder::XmlMarkup.new
end

Public Instance Methods

append(&block) click to toggle source
# File lib/card/bootstrap/tag_method.rb, line 47
def append &block
  @append[-1] << block
end
call(*_args, &content_block) click to toggle source
# File lib/card/bootstrap/tag_method.rb, line 18
def call *_args, &content_block
  component.content.push "".html_safe

  opts = process_content(&content_block)
  process_collected_content tag_name, opts
  process_append
  ""
end
method_missing(method, *args, &block) click to toggle source
Calls superclass method
# File lib/card/bootstrap/tag_method.rb, line 27
def method_missing method, *args, &block
  return super unless respond_to_missing? method

  @component.send method, *args, &block
end
prepend(&block) click to toggle source
# File lib/card/bootstrap/tag_method.rb, line 37
def prepend &block
  tmp = @content.pop
  instance_exec(&block)
  @content << tmp
end
respond_to_missing?(method, _include_private=false) click to toggle source
# File lib/card/bootstrap/tag_method.rb, line 33
def respond_to_missing? method, _include_private=false
  @component.respond_to? method
end
wrap(&block) click to toggle source
# File lib/card/bootstrap/tag_method.rb, line 43
def wrap &block
  instance_exec(&block)
end
wrapInner(tag=nil, &block) click to toggle source
# File lib/card/bootstrap/tag_method.rb, line 51
def wrapInner tag=nil, &block
  @wrap[-1] << (block_given? ? block : tag)
end