class Handlebars::Helpers::Comparison::Or
Or: Block helper that renders a block if **any of** the given values is truthy. If an inverse block is specified it will be rendered when falsy.
@example
{{#if (or p1 p2 p3 p4 p5)}}
found
{{/if}}
@example
{{#if (or
(eq section1 "foo") (ne section2 "bar"))}}
.. content {{/if}}
@example {{#if (or name age)}}
{{name}}-{{age}}
{{else}}
no name or age
{{/if}}
Public Instance Methods
handlebars_helper()
click to toggle source
# File lib/handlebars/helpers/comparison/or.rb, line 49 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 Or: Block helper that renders a block if **any of** the given values is truthy. If an inverse block is specified it will be rendered when falsy.
@example
puts Or.new.parse(var1, var2) truthy block
@param values list of values (via *splat) to be checked via OR condition @return [String] return block when first value is truthy
# File lib/handlebars/helpers/comparison/or.rb, line 45 def parse(values) values.any? { |value| value } end