Module: Cell::Slim::Rails::Helpers

Defined in:
lib/cell/slim/rails.rb

Overview

include after AV helpers to override.

Instance Method Summary collapse

Instance Method Details

#capture(*args) ⇒ Object


17
18
19
20
21
22
23
# File 'lib/cell/slim/rails.rb', line 17

def capture(*args)
  value = nil
  buffer = with_output_buffer { value = yield(*args) }

  return buffer.to_s if buffer.size > 0
  value # this applies for "Beachparty" string-only statements.
end

#concat(string) ⇒ Object


48
49
50
51
# File 'lib/cell/slim/rails.rb', line 48

def concat(string)
  @output_buffer << string
  self
end

#content_tag_string(name, content, options, escape = true) ⇒ Object


44
45
46
# File 'lib/cell/slim/rails.rb', line 44

def (name, content, options, escape=true)
  super(name, content, options, false)
end

#form_tag_html(html_options) ⇒ Object


35
36
37
38
# File 'lib/cell/slim/rails.rb', line 35

def form_tag_html(html_options)
  extra_tags = extra_tags_for_form(html_options)
  "#{tag(:form, html_options, true) + extra_tags}"
end

#form_tag_in_block(html_options, &block) ⇒ Object

From FormTagHelper. why do they escape every possible string? why?


26
27
28
29
# File 'lib/cell/slim/rails.rb', line 26

def form_tag_in_block(html_options, &block)
  content = capture(&block)
  form_tag_with_body(html_options, content)
end

#form_tag_with_body(html_options, content) ⇒ Object


31
32
33
# File 'lib/cell/slim/rails.rb', line 31

def form_tag_with_body(html_options, content)
  "#{form_tag_html(html_options)}" << content.to_s << "</form>"
end

#tag_options(options, escape = true) ⇒ Object


40
41
42
# File 'lib/cell/slim/rails.rb', line 40

def tag_options(options, escape = true)
  super(options, true)
end

#with_output_buffer(block_buffer = ViewModel::OutputBuffer.new) ⇒ Object


9
10
11
12
13
14
15
# File 'lib/cell/slim/rails.rb', line 9

def with_output_buffer(block_buffer=ViewModel::OutputBuffer.new)
  @output_buffer, old_buffer = block_buffer, @output_buffer
  yield
  @output_buffer = old_buffer

  block_buffer
end