Class: Synvert::Core::Engine::Erb
- Inherits:
-
Object
- Object
- Synvert::Core::Engine::Erb
- Defined in:
- lib/synvert/core/engine/erb.rb
Class Method Summary collapse
-
.encode(source) ⇒ String
Encode erb string, leave only ruby code, replace other erb code with whitespace.
Class Method Details
.encode(source) ⇒ String
Encode erb string, leave only ruby code, replace other erb code with whitespace.
11 12 13 14 15 |
# File 'lib/synvert/core/engine/erb.rb', line 11 def encode(source) source.gsub(/%>.*?<%=?/m) { |str| replace_all_code_but_white_space_characters(str) } .sub(/^.*?<%=?/m) { |str| replace_all_code_but_white_space_characters(str) } .sub(/%>.*?$/m) { |str| replace_all_code_but_white_space_characters(str) } end |