Sha256: e70e5e587244239ae204ed1e55c3d23e5316405c6c7e22a8baaccf381b181b50

Contents?: true

Size: 993 Bytes

Versions: 2

Compression:

Stored size: 993 Bytes

Contents

module Ramaze
  module Helper

    # Provides shortcuts to the link/script tags.
    module XHTML
      LINK_TAG = '<link href=%p media=%p rel="stylesheet" type="text/css" />'
      SCRIPT_TAG = '<script src=%p type="text/javascript"></script>'

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

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

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ramaze-2010.03 lib/ramaze/helper/xhtml.rb
ramaze-2010.01 lib/ramaze/helper/xhtml.rb