class Card::Bootstrap::OldComponent

not-yet-obviated component handling

Public Class Methods

add_div_method(name, html_class, opts={}) click to toggle source

Like add_tag_method but always generates a div tag The tag option is not available

# File lib/card/bootstrap/old_component.rb, line 24
def add_div_method name, html_class, opts={}, &tag_block
  add_tag_method name, html_class, opts.merge(tag: :div), &tag_block
end
Also aliased as: def_div_method
add_tag_method(name, html_class, tag_opts={}) click to toggle source

Defines a method that generates a html tag @param name [Symbol, String] the name of the method. If no :tag option in

tag_opts is defined then the name is also the name of the tag that the method
generates

@param html_class [String] a html class that is added to tag. Use nil if you

don't want a html_class

@param tag_opts [Hash] additional argument that will be added to the tag @option tag_opts [Symbol, String] tag the name of the tag @example

add_tag_method :link, "known-link", tag: :a, id: "uniq-link"
link  # => <a class="known-link" id="uniq-link"></a>
# File lib/card/bootstrap/old_component.rb, line 39
def add_tag_method name, html_class, tag_opts={}, &tag_block
  define_method name do |*args, &block|
    process_tag tag_opts[:tag] || name do
      content, opts, new_child_args = standardize_args args, &tag_block
      add_classes opts, html_class, tag_opts.delete(:optional_classes)
      if (attributes = tag_opts.delete(:attributes))
        opts.merge! attributes
      end

      content = with_child_args new_child_args do
        generate_content content,
                         tag_opts[:content_processor],
                         &block
      end

      [content, opts]
    end
  end
end
Also aliased as: def_tag_method
def_div_method(name, html_class, opts={})
Alias for: add_div_method
def_tag_method(name, html_class, tag_opts={})
Alias for: add_tag_method
new(context, *args, &block) click to toggle source
# File lib/card/bootstrap/old_component.rb, line 7
def initialize context, *args, &block
  @context = context
  @content = ["".html_safe]
  @args = args
  @child_args = []
  @append = []
  @wrap = []
  @build_block = block
end
render(format, *args, &block) click to toggle source
# File lib/card/bootstrap/old_component.rb, line 18
def render format, *args, &block
  new(format, *args, &block).render
end

Public Instance Methods

render() click to toggle source
# File lib/card/bootstrap/old_component.rb, line 63
def render
  @rendered = begin
    render_content
    @content[-1]
  end
end

Private Instance Methods

html(content) click to toggle source

include BasicTags

# File lib/card/bootstrap/old_component.rb, line 84
def html content
  add_content String(content).html_safe
  ""
end
process_tag(tag_name, &content_block) click to toggle source
# File lib/card/bootstrap/old_component.rb, line 72
def process_tag tag_name, &content_block
  @content.push "".html_safe
  @append << []
  @wrap << []

  opts = process_content(&content_block)
  process_collected_content tag_name, opts
  process_append
  ""
end