Class: Nanoc::Filters::Sass Private

Inherits:
Nanoc::Filter show all
Defined in:
lib/nanoc/filters/sass.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary

Constants inherited from Nanoc::Filter

Nanoc::Filter::TMP_BINARY_ITEMS_DIR

Instance Attribute Summary

Attributes inherited from Nanoc::Filter

#assigns

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Nanoc::Filter

#depend_on, #filename, from_binary?, #initialize, #output_filename, requires, setup, #setup_and_run, to_binary?, type

Methods included from Int::PluginRegistry::PluginMethods

#all, #identifier, #identifiers, #named, #register

Methods inherited from Int::Context

#get_binding, #initialize

Constructor Details

This class inherits a constructor from Nanoc::Filter

Class Method Details

.item_filename_map_for_config(config, items) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/nanoc/filters/sass.rb', line 21

def self.item_filename_map_for_config(config, items)
  @item_filename_map ||= {}
  @item_filename_map[config] ||=
    {}.tap do |map|
      items.each do |item|
        if item.raw_filename
          path = Pathname.new(item.raw_filename).realpath.to_s
          map[path] = item
        end
      end
    end
end

Instance Method Details

#imported_filename_to_item(filename) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



34
35
36
37
38
39
# File 'lib/nanoc/filters/sass.rb', line 34

def imported_filename_to_item(filename)
  realpath = Pathname.new(filename).realpath.to_s

  map = self.class.item_filename_map_for_config(@config, @items)
  map[realpath]
end

#run(content, params = {}) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Runs the content through [Sass](sass-lang.com/). Parameters passed to this filter will be passed on to Sass.

Parameters:

  • content (String)

    The content to filter

Returns:

  • (String)

    The filtered content



12
13
14
15
16
17
18
19
# File 'lib/nanoc/filters/sass.rb', line 12

def run(content, params = {})
  options = params.merge(
    nanoc_current_filter: self,
    filename: @item && @item.raw_filename,
  )
  engine = ::Sass::Engine.new(content, options)
  engine.render
end