Module: Ramaze::Helper::XHTML

Defined in:
lib/ramaze/helper/xhtml.rb

Overview

Provides shortcuts to the link/script tags.

Constant Summary collapse

'<link href=%p media=%p rel="stylesheet" type="text/css" />'
SCRIPT_TAG =
'<script src=%p type="text/javascript"></script>'

Instance Method Summary collapse

Instance Method Details

#css(name, media = 'screen', options = {}) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/ramaze/helper/xhtml.rb', line 9

def css(name, media = 'screen', options = {})
  if options.empty?
    LINK_TAG % ["/css/#{name}.css", media]
  elsif options[:only].to_s.downcase == 'ie'
    "<!--[if IE]>#{css(name, media)}<![endif]-->"
  end
end

#css_for(*args) ⇒ Object



17
18
19
# File 'lib/ramaze/helper/xhtml.rb', line 17

def css_for(*args)
  args.map{|arg| css(*arg) }.join("\n")
end

#js(name) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/ramaze/helper/xhtml.rb', line 21

def js(name)
  if name =~ /^http/ # consider it external full url
    SCRIPT_TAG % name
  else
    SCRIPT_TAG % "/js/#{name}.js"
  end
end

#js_for(*args) ⇒ Object



29
30
31
# File 'lib/ramaze/helper/xhtml.rb', line 29

def js_for(*args)
  args.map{|arg| js(*arg) }.join("\n")
end