Class: REXML::Element

Inherits:
Object show all
Defined in:
lib/lapillus/behaviours.rb,
lib/lapillus/html_visitor.rb,
lib/lapillus/html_visitor.rb

Instance Method Summary collapse

Instance Method Details

#accept(visitor) ⇒ Object



70
71
72
# File 'lib/lapillus/html_visitor.rb', line 70

def accept(visitor)
  visitor.visit_element(self)
end

#add_javascript(javascript) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/lapillus/behaviours.rb', line 6

def add_javascript(javascript)
  script = REXML::Element.new('script')
  script.add_attributes({'type'=>'text/javascript', 'language'=>'javascript'})
  text=REXML::Text.new("\n// <![CDATA[\n#{javascript}\n// ]]>\n")
  def text.to_s
    @normalized=@string
  end
  script.add_text(text)
  self.add_element(script)
end

#attribute(name, namespace = nil) ⇒ Object



8
9
10
11
12
13
# File 'lib/lapillus/html_visitor.rb', line 8

def attribute( name, namespace=nil )
  prefix = nil
  prefix = namespaces.index(namespace) if namespace
  prefix = nil if prefix == 'xmlns'
  attributes.get_attribute( "#{prefix ? prefix + ':' : ''}#{name}" )
end