Sha256: 05b59cb2a6b3d77173ed26a5894d47087d83a300233b3ce6bdaefac5a904b3d5

Contents?: true

Size: 1.16 KB

Versions: 61

Compression:

Stored size: 1.16 KB

Contents

require 'spiderfw/templates/template_blocks'

module Spider; module TemplateBlocks
    
    class If < Block
        
        def compile(options={})
            init = ""
            init_cond = nil
            if_attr = @el.attributes['sp:if'] || @el.attributes['sp:run-if']
            init_cond = vars_to_scene(@el.attributes['sp:if'], 'scene') if @el.attributes['sp:if']
            run_cond = vars_to_scene(if_attr)
            c = "if (#{run_cond})\n"
            @el.remove_attribute('sp:if')
            @el.remove_attribute('sp:run-if')
            content = Spider::TemplateBlocks.parse_element(@el, @allowed_blocks, @template).compile(options)
            content.run_code.each_line do |line|
                c += '  '+line
            end
            c += "end\n"
            unless (!content.init_code || content.init_code.strip.empty?)
                init += "if (#{init_cond})\n" if init_cond
                content.init_code.each_line do |line|
                    init += "  #{line}"
                end
                init += "end\n" if init_cond
            end
            return CompiledBlock.new(init, c)
        end
        
        
    end
    
    
end; end

Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
spiderfw-1.0.1 lib/spiderfw/templates/blocks/if.rb
spiderfw-1.0.0 lib/spiderfw/templates/blocks/if.rb
spiderfw-0.6.39 lib/spiderfw/templates/blocks/if.rb
spiderfw-0.6.38 lib/spiderfw/templates/blocks/if.rb
spiderfw-0.6.37 lib/spiderfw/templates/blocks/if.rb
spiderfw-0.6.35 lib/spiderfw/templates/blocks/if.rb
spiderfw-0.6.34 lib/spiderfw/templates/blocks/if.rb
spiderfw-0.6.33 lib/spiderfw/templates/blocks/if.rb
spiderfw-0.6.32 lib/spiderfw/templates/blocks/if.rb
spiderfw-0.6.31 lib/spiderfw/templates/blocks/if.rb
spiderfw-0.6.30 lib/spiderfw/templates/blocks/if.rb
spiderfw-0.6.29 lib/spiderfw/templates/blocks/if.rb
spiderfw-0.6.28 lib/spiderfw/templates/blocks/if.rb
spiderfw-0.6.27 lib/spiderfw/templates/blocks/if.rb
spiderfw-0.6.26 lib/spiderfw/templates/blocks/if.rb
spiderfw-0.6.26.pre1 lib/spiderfw/templates/blocks/if.rb
spiderfw-0.6.25 lib/spiderfw/templates/blocks/if.rb
spiderfw-0.6.24 lib/spiderfw/templates/blocks/if.rb
spiderfw-0.6.23 lib/spiderfw/templates/blocks/if.rb
spiderfw-0.6.22 lib/spiderfw/templates/blocks/if.rb