module Sass::Script::Functions

Public Instance Methods

relocatable(path) click to toggle source

Return the correct relative path for the given path.

# File lib/webgen/content_processor/sass.rb, line 108
def relocatable(path)
  assert_type(path, :String)
  context = options[:webgen_context]
  path = path.value

  ref_node = context.website.tree[options[:filename]]
  ref_node = context.website.tree.root if ref_node.nil? && path[0] == ?/

  if ref_node
    if dest_node = ref_node.resolve(path, context.dest_node.lang, true)
      context.website.ext.item_tracker.add(context.dest_node, :node_meta_info, dest_node)
      path = context.dest_node.route_to(dest_node)
    end
  else
    context.website.logger.warn { "Couldn't determine reference node for resolving node in Sass file." }
  end
  ::Sass::Script::String.new(path, :string)
end