Class: SassC::Rails::SassTemplate
- Inherits:
-
Sprockets::SassProcessor
- Object
- Sprockets::SassProcessor
- SassC::Rails::SassTemplate
- Defined in:
- lib/sassc/rails/template.rb
Direct Known Subclasses
Defined Under Namespace
Modules: Functions
Constant Summary collapse
- PASS_THRU_OPTIONS =
%i[ style charset importers logger alert_ascii alert_color verbose quiet_deps silence_deprecations fatal_deprecations future_deprecations ].freeze
Instance Method Summary collapse
-
#call(input) ⇒ Object
rubocop:disable Metrics/AbcSize.
-
#initialize(options = {}, &block) ⇒ SassTemplate
constructor
rubocop:disable Lint/MissingSuper.
Constructor Details
#initialize(options = {}, &block) ⇒ SassTemplate
rubocop:disable Lint/MissingSuper
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/sassc/rails/template.rb', line 25 def initialize( = {}, &block) # rubocop:disable Lint/MissingSuper @cache_version = [:cache_version] @cache_key = "#{self.class.name}:#{VERSION}:#{::SassC::VERSION}:#{@cache_version}" @importer_class = [:importer] || ::SassC::Rails::Importer @sass_config = [:sass_config] || {} @functions = Module.new do include ::SassC::Script::Functions include Functions include [:functions] if [:functions] class_eval(&block) if block_given? end end |
Instance Method Details
#call(input) ⇒ Object
rubocop:disable Metrics/AbcSize
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/sassc/rails/template.rb', line 38 def call(input) # rubocop:disable Metrics/AbcSize context = input[:environment].context_class.new(input) = { load_paths: input[:environment].paths | (::Rails.application.config.sass.load_paths || []), filename: input[:filename], syntax: self.class.syntax, functions: @functions, importer: @importer_class, sprockets: { context: context, environment: input[:environment], dependencies: context.[:dependency_paths] } } PASS_THRU_OPTIONS.each do |option| [option] = ::Rails.application.config.sass.send(option) end if ::Rails.application.config.sass.inline_source_maps .merge!(source_map_file: '.', source_map_embed: true, source_map_contents: true) end engine = ::SassC::Engine.new(input[:data], .compact) css = engine.render # Track all imported files sass_dependencies = Set.new([input[:filename]]) engine.dependencies.map do |dependency| sass_dependencies << dependency.[:filename] context.[:dependencies] << Sprockets::URIUtils.build_file_digest_uri(dependency.[:filename]) end context..merge(data: css, sass_dependencies: sass_dependencies) end |