Class: Erector::Widget

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

Instance Method Summary collapse

Instance Method Details

#css(href, args = {}) ⇒ Object

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.



101
102
103
104
105
106
107
108
109
# File 'lib/ramaze/helper/erector.rb', line 101

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

  link attrs
end

#ie_if(expr, &block) ⇒ Object

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.



75
76
77
78
79
# File 'lib/ramaze/helper/erector.rb', line 75

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

#inspect(elem) ⇒ Object

Inspect the specified element.

Parameters:

  • elem (String)

    The element to inspect.



86
87
88
# File 'lib/ramaze/helper/erector.rb', line 86

def inspect(elem)
  text elem.inspect
end

#js(src) ⇒ Object

Generate a Javascript tag.

Examples:

js 'javascript/jquery.js'

Parameters:

  • src (String)

    The full or relative path to the Javascript file.



59
60
61
# File 'lib/ramaze/helper/erector.rb', line 59

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

#old_cssObject



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

alias :old_css :css

#strict_xhtml(*args, &block) ⇒ Object

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.



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

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