Module: WrapIt::TextContainer

Included in:
Link
Defined in:
lib/wrap_it/text_container.rb

Overview

TextContainer

Author:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



28
29
30
# File 'lib/wrap_it/text_container.rb', line 28

def body
  @body
end

Class Method Details

.included(base) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/wrap_it/text_container.rb', line 8

def self.included(base)
  base.class_eval do
    default_tag 'p', false

    section :body
    place :body, :before, :content

    after_initialize do
      @body = @arguments.extract_first!(String) || empty_html
      @body += @options[:body] || @options[:text] || empty_html
      @options.delete(:body)
      @options.delete(:text)
    end

    after_capture do
      self[:body] = html_safe(@body) unless @body.nil?
    end
  end
end