Class: Plate::ScriptNode

Inherits:
Struct
  • Object
show all
Defined in:
lib/plate/nodes.rb,
lib/plate/compiler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bodyObject

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



21
22
23
# File 'lib/plate/nodes.rb', line 21

def body
  @body
end

#eventObject

Returns the value of attribute event

Returns:

  • (Object)

    the current value of event



21
22
23
# File 'lib/plate/nodes.rb', line 21

def event
  @event
end

Instance Method Details

#compile(compiler, parent = nil) ⇒ Object



120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/plate/compiler.rb', line 120

def compile(compiler, parent = nil)
  b = body.compile(compiler, self)
  key, val = case event
        when /repeat/
          ['repeat', b]
        else
          ['on', "#{event}: #{b}"]
        end
  parent.scripts[key] = [] if parent.scripts[key].nil?
  parent.scripts[key] << val
  ''
end