Module: MetaRuby::GUI::HTML

Defined in:
lib/metaruby/gui/html.rb,
lib/metaruby/gui/html/page.rb,
lib/metaruby/gui/html/button.rb,
lib/metaruby/gui/html/collection.rb

Overview

Basic functionality to generate HTML pages

The core functionality is in Page

Defined Under Namespace

Classes: Button, Collection, HTMLPage, Page

Constant Summary collapse

RESSOURCES_DIR =

The directory relative to which ressources (such as css or javascript files) are resolved by default

File.expand_path(File.dirname(__FILE__))

Class Method Summary collapse

Class Method Details

.escape_html(string) ⇒ String

Escape the string to include in HTML

Parameters:

  • string (String)

Returns:

  • (String)


16
17
18
19
20
# File 'lib/metaruby/gui/html.rb', line 16

def self.escape_html(string)
    string.
        gsub('<', '&lt;').
        gsub('>', '&gt;')
end

.render_button_bar(buttons) ⇒ String

Render a button bar into HTML

Parameters:

Returns:

  • (String)


99
100
101
102
103
# File 'lib/metaruby/gui/html/button.rb', line 99

def self.render_button_bar(buttons)
    if !buttons.empty?
        "<div class=\"button_bar\"><span>#{buttons.map(&:render).join(" / ")}</span></div>"
    end
end