Class: Nanoc::DartSass::Filter

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

Defined Under Namespace

Classes: NanocImporter

Instance Method Summary collapse

Instance Method Details

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

Runs the content through [Dart Sass](sass-lang.com/dart-sass). Parameters passed as ‘:args` will be passed on to Dart Sass.

Parameters:

  • content (String)

    The content to filter

Returns:

  • (String)

    The filtered content



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/nanoc/dart_sass/filter.rb', line 14

def run(content, params = {})
  # Read syntax
  syntax = params[:syntax]
  syntax ||= Util.syntax_from_ext(item.identifier.ext)

  result = Sass.compile_string(
    content,
    importer: NanocImporter.new(@items, item),
    **params,
    syntax:,
  )
  result.css
end