Sha256: febc1720119316a7d1b9124b242bdc020f2a6ed1412bf83b355e7f07b5aa9fff
Contents?: true
Size: 1.05 KB
Versions: 12
Compression:
Stored size: 1.05 KB
Contents
module ExpressTemplates module Components class UnlessBlock < Components::Container attr :conditional def initialize(*args) @conditional = args.shift @alt = args.shift[:alt] if args.first.kind_of?(Hash) parent = args.shift if @conditional.kind_of?(Symbol) @conditional = @conditional.to_s elsif @conditional.kind_of?(Proc) @conditional = "(#{@conditional.source}.call)" elsif iterator.kind_of?(String) @conditional = "(#{@conditional}.call)" else raise "UnlessBlock unknown conditional: #{@conditional.inspect}" end if @alt.kind_of?(Proc) @alt = _compile_fragment @alt elsif @alt.nil? @alt = "''" end end def compile s = unless @alt %Q((unless #{@conditional}#{compile_children}\nend)) else %Q((unless #{@conditional}#{compile_children}\nelse #{@alt}\nend)) end puts s if ENV['DEBUG'].eql?('true') s end end end end
Version data entries
12 entries across 12 versions & 2 rubygems