Module: Lipstick::Helpers::CompatibilityHacks

Defined in:
lib/lipstick/helpers/compatibility_hacks.rb

Instance Method Summary collapse

Instance Method Details

#captureObject



19
20
21
22
23
24
25
26
27
# File 'lib/lipstick/helpers/compatibility_hacks.rb', line 19

def capture
  old = @_out_buf
  @_out_buf = io = StringIO.new
  result = yield
  io_length = io.length
  io_length.positive? ? io.string : result
ensure
  @_out_buf = old
end

#concat(content) ⇒ Object



5
6
7
# File 'lib/lipstick/helpers/compatibility_hacks.rb', line 5

def concat(content)
  @_out_buf << content
end

#content_tag(name, content_or_opts = nil, opts = nil, &block) ⇒ Object



9
10
11
12
13
# File 'lib/lipstick/helpers/compatibility_hacks.rb', line 9

def (name, content_or_opts = nil, opts = nil, &block)
  opts = content_or_opts if block_given?
  content = block_given? ? capture(&block) : content_or_opts
  "<#{name}#{html_attrs(opts)}>#{content}</#{name}>"
end

#tag(name, opts = nil) ⇒ Object



15
16
17
# File 'lib/lipstick/helpers/compatibility_hacks.rb', line 15

def tag(name, opts = nil)
  "<#{name}#{html_attrs(opts)}/>"
end