Module: JsCodeWrapper

Defined in:
lib/js-code-wrapper.rb

Instance Method Summary collapse

Instance Method Details

#wrap_js_code(text) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/js-code-wrapper.rb', line 2

def wrap_js_code(text)
  code_coords = code_tag_coords(text)
  matches_count = script_to_code_tags_inclusion(text, code_coords).count {|t| !t}

  while matches_count > 0 do
    text = insert_code_tags(text, code_coords)
    matches_count = matches_count - 1
    code_coords = code_tag_coords(text)
  end

  text
end