Class: Erector::Widget

Inherits:
Object show all
Defined in:
lib/ramaze/helper/erector.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) css(href, args = {})

Generate a stylesheet tag.

Examples:

css 'css/reset.css', :media => 'print'

Parameters:

  • href (String)

    The path (either absolute or relative) to the CSS file.

  • args (Hash) (defaults to: {})

    A hash containing additional arguments to add to the CSS tag.



105
106
107
108
109
110
111
112
113
# File 'lib/ramaze/helper/erector.rb', line 105

def css(href, args = {})
  attrs = {
    :rel => "stylesheet", 
    :href => href, 
    :type => "text/css" 
  }.merge(args)

  link attrs
end

- (Object) ie_if(expr, &block)

Generate a pair of conditional tags for a specific browser.

Examples:

ie_if 'IE' do
  ......
end

Parameters:

  • expr (String)

    The if expression, such as ‘IE’ or ‘lte IE7’.

  • block (block)

    Block that contains the data that needs to be loaded for the specified browser.



78
79
80
81
82
# File 'lib/ramaze/helper/erector.rb', line 78

def ie_if(expr, &block)
  raw! "<!--[if #{expr}]>"
  yield
  raw! "<![endif]-->"
end

- (Object) inspect(elem)

Inspect the specified element.

Parameters:

  • elem (String)

    The element to inspect.



89
90
91
# File 'lib/ramaze/helper/erector.rb', line 89

def inspect(elem)
  text elem.inspect
end

- (Object) js(src)

Generate a Javascript tag.

Examples:

js 'javascript/jquery.js'

Parameters:

  • src (String)

    The full or relative path to the Javascript file.



61
62
63
# File 'lib/ramaze/helper/erector.rb', line 61

def js(src)
  script :src => src
end

- (Object) old_css



23
# File 'lib/ramaze/helper/erector.rb', line 23

alias :old_css :css

- (Object) strict_xhtml(*args, &block)

Method that generates a XHTML 1.0 Strict doctype.

Examples:

strict_html do
  head do
    title "Ramaze Rocks!"
  end
  body
    div do

    end
  end
end

Parameters:

  • args (Hash)

    Hash containing extra options such as the xml:lang and xmlns attribute.

  • block (Block)

    Block that contains the inner data of the <html> element.



46
47
48
49
50
# File 'lib/ramaze/helper/erector.rb', line 46

def strict_xhtml(*args, &block)
  raw! '<?xml version="1.0" encoding="UTF-8"?>'
  raw! '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">'
  html(:xmlns => "http://www.w3.org/1999/xhtml", :"xml:lang" => "en", :lang => "en", &block)
end