Sha256: fa76c811cd46c6fabeebca21fe2407d54e12440e8f1a14ea6cfea24106d08b92
Contents?: true
Size: 859 Bytes
Versions: 18
Compression:
Stored size: 859 Bytes
Contents
module Wovnrb class HtmlReplaceMarker KEY_PREFIX = '__wovn-backend-ignored-key-'.freeze def initialize @current_key_number = 0 @mapped_values = [] end # Add argument's value to mapping information with comment style key def add_comment_value(value) key = "<!-- #{generate_key} -->" @mapped_values << [key, value] key end def add_value(value) key = generate_key @mapped_values << [key, value] key end def revert(marked_html) i = @mapped_values.size while i > 0 i -= 1 key, value = @mapped_values[i] marked_html = marked_html.sub(key, value) end marked_html end private def generate_key next_key = "#{KEY_PREFIX}#{@current_key_number}" @current_key_number += 1 next_key end end end
Version data entries
18 entries across 18 versions & 1 rubygems