class Handlebars::Helpers::Comparison::And

And: Block helper that renders a block if **all of** the given values are truthy. If an inverse block is specified it will be rendered when falsy.

Public Instance Methods

handlebars_helper() click to toggle source
# File lib/handlebars/helpers/comparison/and.rb, line 37
def handlebars_helper
  # Exclude last paramater which is the context V8::Object
  proc { |_context, *values| wrapper(parse(values[0..-2])) }
end
parse(values) click to toggle source

Parse will And: Block helper that renders a block if **all of** the given values are truthy. If an inverse block is specified it will be rendered when falsy.

@example

{{#if (and p1 p2 p3 p4 p5)}}

found

{{/if}}

@example

@example {{#if (and name age)}}

{{name}}-{{age}}

{{else}}

no name or age

{{/if}}

@param values list of values (via *splat) to be checked via AND condition @return [String] return block when every value is truthy

# File lib/handlebars/helpers/comparison/and.rb, line 33
def parse(values)
  values.all? { |value| value }
end