Sha256: 1aba5425d0e5ad9850cc6edfe5f8a9bbc46e826305baedb8acff47e3bd3427ae
Contents?: true
Size: 815 Bytes
Versions: 2
Compression:
Stored size: 815 Bytes
Contents
# frozen_string_literal: true require_relative 'if' module Liquid # Unless is a conditional just like 'if' but works on the inverse logic. # # {% unless x < 0 %} x is greater than zero {% endunless %} # class Unless < If def render_to_output_buffer(context, output) # First condition is interpreted backwards ( if not ) first_block = @blocks.first unless first_block.evaluate(context) return first_block.attachment.render_to_output_buffer(context, output) end # After the first condition unless works just like if @blocks[1..-1].each do |block| if block.evaluate(context) return block.attachment.render_to_output_buffer(context, output) end end output end end Template.register_tag('unless', Unless) end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
liquid-5.0.1 | lib/liquid/tags/unless.rb |
liquid-5.0.0 | lib/liquid/tags/unless.rb |