Class: Proscenium::CssModule::Rewriter
- Inherits:
-
RubyNext::Language::Rewriters::Text
- Object
- RubyNext::Language::Rewriters::Text
- Proscenium::CssModule::Rewriter
- Defined in:
- lib/proscenium/css_module/rewriter.rb
Constant Summary collapse
- NAME =
'proscenium-css-module'
Instance Method Summary collapse
Instance Method Details
#rewrite(source) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/proscenium/css_module/rewriter.rb', line 11 def rewrite(source) source = source.gsub(/%i\[((@[\w@ ]+)|([\w@ ]+ @[\w@ ]+))\]/) do |_| arr = ::Regexp.last_match(1).split.map do |x| x.start_with?('@') ? css_module_string(x[1..]) : ":#{x}" end "[#{arr.join(',')}]" end source.gsub(/:@([\w]+)/) do |_| context.track!(self) css_module_string(::Regexp.last_match(1)) end end |