Class: Handlebars::Helpers::IfHelper

Inherits:
DefaultHelper show all
Defined in:
lib/ruby-handlebars/helpers/if_helper.rb

Class Method Summary collapse

Methods inherited from DefaultHelper

register

Class Method Details

.apply(context, condition, block, else_block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/ruby-handlebars/helpers/if_helper.rb', line 10

def self.apply(context, condition, block, else_block)
  condition = !condition.empty? if condition.respond_to?(:empty?)

  if condition
    block.fn(context)
  elsif else_block
    else_block.fn(context)
  else
    ""
  end
end

.registry_nameObject



6
7
8
# File 'lib/ruby-handlebars/helpers/if_helper.rb', line 6

def self.registry_name
  'if'
end