Module: Flannel::Wrappable

Included in:
HtmlTransformable
Defined in:
lib/flannel/wrappable.rb

Instance Method Summary collapse

Instance Method Details

#empty_string?(str) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/flannel/wrappable.rb', line 17

def empty_string? str
  str.nil? || str.strip == ""
end

#wrap(content, tag, element_id = nil) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/flannel/wrappable.rb', line 3

def wrap content, tag, element_id=nil
  if empty_string?(content) || empty_string?(tag)
    return content
  end

  content.strip! unless tag == "pre"

  if element_id
    "<#{tag} id='#{element_id}'>#{content}</#{tag}>"
  else
    "<#{tag}>#{content}</#{tag}>"
  end
end