class Pakyow::Assets::Types::CSS

Public Class Methods

new(local_path:, config:, **kwargs) click to toggle source
Calls superclass method Pakyow::Assets::Asset::new
# File lib/pakyow/assets/types/css.rb, line 13
def initialize(local_path:, config:, **kwargs)
  super

  @options = @config.sass.to_h
  @options[:filename] = @local_path.to_s
  @options[:syntax] = :scss

  if @config.source_maps
    @options[:source_map_file] = File.basename(@local_path.to_s)
  end
end

Public Instance Methods

process(content) click to toggle source
# File lib/pakyow/assets/types/css.rb, line 25
def process(content)
  @engine = ::SassC::Engine.new(content, @options)
  @engine.render
rescue StandardError => error
  Pakyow.logger.error "[#{self.class}] #{error}"

  # Be sure to return a string.
  #
  content
end
source_map_content() click to toggle source
# File lib/pakyow/assets/types/css.rb, line 36
def source_map_content
  ensure_content
  @engine.source_map
rescue SassC::NotRenderedError
  nil
end