Sha256: 22dc62cbede655a283c763b49246f9cca9ab39d6e64a148dc3290a8479534fa0

Contents?: true

Size: 803 Bytes

Versions: 12

Compression:

Stored size: 803 Bytes

Contents

include_set Abstract::Scss
include_set Abstract::AssetInputter, input_format: :scss

event :validate_scss_syntax, :validate, on: :save, changed: %i[type_id content] do
  variables = Card[:all, :style]&.joined_items_content
  return unless variables.present? # happens during card:seed:build

  SassC::Engine.new([variables.strip, content].join("\n")).render
rescue SassC::SyntaxError => e
  match = e.message.match(/line (\d+)/)
  message =
    if match
      offset = 6
      corrected_line = match[1].to_i - variables.lines.count + offset
      e.message
       .sub(/line \d+:(\d+) of stdin/, "line #{corrected_line}:\\1")
       .sub(/>>.*$/, ">> #{content.lines[corrected_line - 1]}")
      # e.message
    else
      e.message
    end
  errors.add(:content, "<pre>#{message}</pre>".html_safe)
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
card-mod-style-0.18.1 set/type/scss.rb
card-mod-style-0.18.0 set/type/scss.rb
card-mod-style-0.17.0 set/type/scss.rb
card-mod-style-0.16.0 set/type/scss.rb
card-mod-style-0.15.6 set/type/scss.rb
card-mod-style-0.15.5 set/type/scss.rb
card-mod-style-0.15.4 set/type/scss.rb
card-mod-style-0.15.3 set/type/scss.rb
card-mod-style-0.15.2.pre1 set/type/scss.rb
card-mod-style-0.15.1.1 set/type/scss.rb
card-mod-style-0.15.1 set/type/scss.rb
card-mod-style-0.15.0 set/type/scss.rb