Sha256: fa269adac22463f96cbb92dc288337c7986e5d4f6844536ccdcc452ec2f16bc2
Contents?: true
Size: 766 Bytes
Versions: 2
Compression:
Stored size: 766 Bytes
Contents
require File.dirname(__FILE__) + '/if' module Liquid # Unless is a conditional just like 'if' but works on the inverse logic. # # {% unless x < 0 %} x is greater than zero {% end %} # class Unless < If def render(context) context.stack do # First condition is interpreted backwards ( if not ) block = @blocks.first unless block.evaluate(context) return render_all(block.attachment, context) end # After the first condition unless works just like if @blocks[1..-1].each do |block| if block.evaluate(context) return render_all(block.attachment, context) end end '' end end end Template.register_tag('unless', Unless) end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
locomotive_liquid-2.4.2 | lib/liquid/tags/unless.rb |
locomotive_liquid-2.4.1 | lib/liquid/tags/unless.rb |