Class: Aurita::GUI::HTML

Inherits:
Object
  • Object
show all
Defined in:
lib/aurita-gui/html.rb,
lib/aurita-gui/javascript.rb

Overview

class

Class Method Summary collapse

Class Method Details

.brObject

Statically defined as <br /> must not have any attributes.



285
286
287
# File 'lib/aurita-gui/html.rb', line 285

def self.br
  Element.new(:tag => :br)
end

.build(&block) ⇒ Object

Raises:

  • (::Exception)


296
297
298
299
# File 'lib/aurita-gui/html.rb', line 296

def self.build(&block)
  raise ::Exception.new('Missing block for HTML.render') unless block_given?
  Element.new(:tag => :pseudo) { self.class_eval(&block) }
end

.js(&block) ⇒ Object



158
159
160
161
162
163
164
# File 'lib/aurita-gui/javascript.rb', line 158

def self.js(&block) 
  if block_given? then 
    Javascript.build(&block)
  else
    Javascript
  end
end

.method_missing(meth_name, *attribs, &block) ⇒ Object



308
309
310
# File 'lib/aurita-gui/html.rb', line 308

def self.method_missing(meth_name, *attribs, &block)
  render(meth_name, *attribs, &block) 
end

.p(*attribs, &block) ⇒ Object

p is defined in Kernel, so we have to redirect it manually (method_missing won’t be triggered for it)



304
305
306
# File 'lib/aurita-gui/html.rb', line 304

def self.p(*attribs, &block)
  render(:p, *attribs, &block)
end

.puts(arg) ⇒ Object



312
313
314
# File 'lib/aurita-gui/html.rb', line 312

def self.puts(arg)
  HTML.build { arg }
end

.render(meth_name, *args, &block) ⇒ Object

Raises:

  • (::Exception)


289
290
291
292
293
294
# File 'lib/aurita-gui/html.rb', line 289

def self.render(meth_name, *args, &block)
  raise ::Exception.new('Missing attributes for HTML.' << meth_name.inspect) unless args
  e = Element.new(*args, &block)
  e.tag = meth_name
  e
end