module Amber::Render::HtmlHelper

Public Instance Methods

amber_path(page_or_array, locale=I18n.locale) click to toggle source

returns the ideal full url path for a page or path (expressed as an array).

# File lib/amber/render/helpers/html_helper.rb, line 80
def amber_path(page_or_array, locale=I18n.locale)
  page = nil
  if page_or_array.is_a? Array
    page = @site.find_page_by_path(page_or_array)
  elsif page_or_array.is_a? StaticPage
    page = page_or_array
  end
  if page.nil?
    return ''
  end
  full_path = []
  full_path << @site.path_prefix if @site.path_prefix
  full_path << locale # always do this?
  if page.aliases(locale).any?
    full_path += page.aliases(locale).first
  else
    full_path += page.path
  end
  "/" + full_path.join('/')
end
html_head_base() click to toggle source

return html markup suitable for setting the href base of the document. If this is added to the document's HEAD, then relative urls will work as expected even though the url path does not end with a '/'

# File lib/amber/render/helpers/html_helper.rb, line 11
def html_head_base
  if @page
    "<base href=\"#{amber_path(@page)}/\" />"
  else
    ""
  end
end
time_tag(date_or_time, *args, &block) click to toggle source
# File lib/amber/render/helpers/date_helper.rb, line 4
def time_tag(date_or_time, *args, &block)
  options  = args.last.is_a?(Hash) ? args.pop : {}
  format   = options.delete(:format) || :long
  content  = args.first || I18n.l(date_or_time, :format => format)
  #datetime = date_or_time.acts_like?(:time) ? date_or_time.xmlschema : date_or_time.iso8601
  datetime = date_or_time.iso8601
  content_tag(:time, content, {:datetime => datetime}.merge(options), &block)
end