class Rapper::HtmlTags::Tag

Represents an HTML tag.

Public Class Methods

for( path, version, style ) click to toggle source

Build an HTML tag for a given resource in a given HTML style.

@param [String] path Publically accessible path to the asset file.

@param [String,nil] version Version string to append as a query string.

@param [Symbol] style HTML tag style. One of ‘:html`, `:html5`, or `:xhtml`.

@return [String] The appropriate HTML tag to include the resource.

# File lib/rapper/html_tags.rb, line 115
def for( path, version, style )
  @cache ||= {}
  @cache[style] ||= {}
  
  if version
    path << "?v=#{version}"
  end
  
  unless @cache[style][path] && @cache[style][path]
    @cache[style][path] = ERB.new( templates[style] ).result( binding )
  end
  
  @cache[style][path]
end
templates() click to toggle source

@return [Hash] A mapping of HTML styles to their appropriate HTML tag template strings.

# File lib/rapper/html_tags.rb, line 100
def templates
  { :html => '', :html5 => '', :xhtml => '' }
end