Module: Serbea::Helpers

Included in:
Bridgetown::SerbeaView, ComponentRenderer
Defined in:
lib/serbea/helpers.rb

Instance Method Summary collapse

Instance Method Details

#capture(obj = nil) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/serbea/helpers.rb', line 3

def capture(obj=nil)
  previous_buffer_state = @_erbout
  @_erbout = +""
  result = obj ? yield(obj) : yield
  @_erbout = previous_buffer_state

  result.respond_to?(:html_safe) ? result.html_safe : result
end

#h(input) ⇒ Object Also known as: escape



20
21
22
# File 'lib/serbea/helpers.rb', line 20

def h(input)
  Erubi.h(input)
end

#helper(name, &block) ⇒ Object



16
17
18
# File 'lib/serbea/helpers.rb', line 16

def helper(name, &block)
  self.class.send(:define_method, name, &block)
end

#pipeline(context, value) ⇒ Object



12
13
14
# File 'lib/serbea/helpers.rb', line 12

def pipeline(context, value)
  Pipeline.new(context, value)
end