Module: Awestruct::Extensions::Relative

Included in:
Assets, Assets::Extension::Extension
Defined in:
lib/awestruct/extensions/relative.rb

Instance Method Summary collapse

Instance Method Details

#relative(href, p = page) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/awestruct/extensions/relative.rb', line 7

def relative(href, p = page)
  begin
    Pathname.new(href).relative_path_from(Pathname.new(File.dirname(p.output_path))).to_s
  rescue Exception => e
    $LOG.error "#{e}" if $LOG.error?
    $LOG.error "#{e.backtrace.join("\n")}" if $LOG.error?
  end
end