Sha256: f88aefa1d963fe0806ac9213f9249a03baf4a466df473703bf6eb318c55e44b6

Contents?: true

Size: 828 Bytes

Versions: 8

Compression:

Stored size: 828 Bytes

Contents

# frozen_string_literal: true

require 'ruby-next/language'
require 'proscenium/core_ext/object/css_module_ivars'

module Proscenium
  module CssModule
    class Rewriter < RubyNext::Language::Rewriters::Text
      NAME = 'proscenium-css-module'

      def safe_rewrite(source)
        source.gsub(/:@([\w_]+)/) do |_|
          context.track! self

          match = ::Regexp.last_match(1)
          "Proscenium::CssModule::Name.new(:@#{match}, css_module(:#{match}))"
        end
      end
    end
  end
end

RubyNext::Language.send :include_patterns=, []
RubyNext::Language.include_patterns << "#{Rails.root.join('app', 'components')}/*.rb"
RubyNext::Language.include_patterns << "#{Rails.root.join('app', 'views')}/*.rb"
RubyNext::Language.rewriters = [Proscenium::CssModule::Rewriter]

require 'ruby-next/language/runtime'

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
proscenium-0.15.0.beta.3-x86_64-linux lib/proscenium/css_module/rewriter.rb
proscenium-0.15.0.beta.3-aarch64-linux lib/proscenium/css_module/rewriter.rb
proscenium-0.15.0.beta.3-arm64-darwin lib/proscenium/css_module/rewriter.rb
proscenium-0.15.0.beta.3-x86_64-darwin lib/proscenium/css_module/rewriter.rb
proscenium-0.15.0.beta.2-x86_64-linux lib/proscenium/css_module/rewriter.rb
proscenium-0.15.0.beta.2-aarch64-linux lib/proscenium/css_module/rewriter.rb
proscenium-0.15.0.beta.2-arm64-darwin lib/proscenium/css_module/rewriter.rb
proscenium-0.15.0.beta.2-x86_64-darwin lib/proscenium/css_module/rewriter.rb