Class: RBlade::CompilesComments
- Inherits:
-
Object
- Object
- RBlade::CompilesComments
- Defined in:
- lib/rblade/compiler/compiles_comments.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.comment_offsets(source) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rblade/compiler/compiles_comments.rb', line 14 def self.comment_offsets(source) current_match_id = nil offsets = [] source.split(/(\{\{--(?:[^-]++|-)*?--}}|<%#(?:[^%]++|%)*?%>)/) do |before_match| next if current_match_id == $~.object_id || $&.nil? current_match_id = $~.object_id offsets << { source_position: (offsets.last&.[](:source_position) || 0) + before_match.length, offset: $&.length, } end offsets end |
Instance Method Details
#compile!(tokens) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/rblade/compiler/compiles_comments.rb', line 5 def compile!(tokens) tokens.each do |token| next if token.type != :unprocessed token.value.gsub!(/\{\{--(?:[^-]++|-)*?--}}/, "") token.value.gsub!(/<%#(?:[^%]++|%)*?%>/, "") end end |