Class: Spider::TemplateBlocks::ParentContext

Inherits:
Block show all
Defined in:
lib/spiderfw/templates/blocks/parent_context.rb

Overview

sp:parent-context  Executes the content using the parent’s scene

Instance Attribute Summary

Attributes inherited from Block

#allowed_blocks, #doctype, #el, #template

Instance Method Summary collapse

Methods inherited from Block

#compile_content, #compile_text, #escape_text, #get_following, #initialize, #inspect, #parse_content, var_to_scene, #var_to_scene, #vars_to_scene, vars_to_scene

Constructor Details

This class inherits a constructor from Spider::TemplateBlocks::Block

Instance Method Details

#compile(options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/spiderfw/templates/blocks/parent_context.rb', line 10

def compile(options={})
    init = ""
    c = ""
#            c += "debugger\n"
    parent_c, parent_init = compile_content(c, init, options)
    parent_c.gsub!("'", "\\\\'")
    #parent_init.gsub!("'", "\\\\'")
    init = parent_init
    init.gsub!('scene[', 'scene[:_parent][')
    c += "self[:_parent].instance_eval('def __run_block\n;#{parent_c}\nend\n')\n"
    c += "yield :_parent\n"
    return CompiledBlock.new(init, c)
end