Class: Wunderbar::ScriptNode

Inherits:
CDATANode show all
Defined in:
lib/wunderbar/node.rb,
lib/wunderbar/script.rb

Constant Summary

Constants inherited from Node

Node::ESCAPE, Node::VOID

Instance Attribute Summary collapse

Attributes inherited from Node

#attrs, #children, #name, #node, #parent, #text

Instance Method Summary collapse

Methods inherited from CDATANode

normalize

Methods inherited from PreformattedNode

#preserve_spaces?

Methods inherited from Node

#add_child, #at, #initialize, #method_missing, parse_css_selector, #preserve_spaces?, #root, #search, #walk

Constructor Details

This class inherits a constructor from Wunderbar::Node

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Wunderbar::Node

Instance Attribute Details

#bindingObject

Returns the value of attribute binding.



10
11
12
# File 'lib/wunderbar/script.rb', line 10

def binding
  @binding
end

#blockObject

Returns the value of attribute block.



10
11
12
# File 'lib/wunderbar/script.rb', line 10

def block
  @block
end

Instance Method Details

#postObject



352
# File 'lib/wunderbar/node.rb', line 352

def post; "//]]>"; end

#preObject



351
# File 'lib/wunderbar/node.rb', line 351

def pre; "//<![CDATA["; end

#serialize(options, result, indent) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/wunderbar/script.rb', line 11

def serialize(options, result, indent)
  if @block and @children.empty? and not @text
    width = options[:width]
    width -= indent.to_s.length if width
    @text = Ruby2JS.convert(@block, binding: @binding, width: width)
  end
  super
end