Module: Sass::Script::Functions

Defined in:
lib/webgen/content_processor/sass.rb

Instance Method Summary collapse

Instance Method Details

#relocatable(path) ⇒ Object

Return the correct relative path for the given path.



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/webgen/content_processor/sass.rb', line 109

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