Class: Nanoc::DartSass::Filter::NanocImporter

Inherits:
Object
  • Object
show all
Defined in:
lib/nanoc/dart_sass/filter.rb

Instance Method Summary collapse

Constructor Details

#initialize(items, source_item) ⇒ NanocImporter

Returns a new instance of NanocImporter.



29
30
31
32
# File 'lib/nanoc/dart_sass/filter.rb', line 29

def initialize(items, source_item)
  @items = items
  @source_item = source_item
end

Instance Method Details

#canonicalize(url) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/nanoc/dart_sass/filter.rb', line 34

def canonicalize(url, *, **)
  # Construct proper URL with `nanoc:` prefix if needed
  if url.start_with?('nanoc:')
    url
  else
    "nanoc:#{url}"
  end
end

#load(url) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/nanoc/dart_sass/filter.rb', line 43

def load(url)
  item = find_item_for_url(url)

  {
    contents: item.raw_content,
    syntax: Util.syntax_from_ext(item.identifier.ext),
  }
end