Module: ErbToSlim::Engine

Includes:
Pattern
Defined in:
lib/erb_to_slim/engine.rb

Instance Method Summary collapse

Methods included from Pattern

#close_tag, #erb_eval_tag, #erb_exec_tag, #html_tag, #html_tags_array, #html_tags_list, #indentation, #js_tag, #multiline_string_which_not_match, #string_literal, #tag_with_class, #tag_with_id

Instance Method Details

#cleanup_close_tagObject



14
15
16
17
# File 'lib/erb_to_slim/engine.rb', line 14

def cleanup_close_tag
  gsub!(close_tag, '')
  self
end

#finally_clean_upObject



51
52
53
54
55
# File 'lib/erb_to_slim/engine.rb', line 51

def finally_clean_up
  gsub!('@ ', '')
  gsub!(/<%= *(.*?) *-?%>/, '#{\1}')
  self
end

#markup_js_tagObject



9
10
11
12
# File 'lib/erb_to_slim/engine.rb', line 9

def markup_js_tag
  gsub!(js_tag) { $&.gsub(/\n[\s\t]*/, '\&@ ') }
  self
end

#replace_erb_eval_tagObject



29
30
31
32
33
34
# File 'lib/erb_to_slim/engine.rb', line 29

def replace_erb_eval_tag
  gsub!(erb_eval_tag) do
    $2.nil? ? "#$1= #{$3.gsub(/\n[\s\t]*/, '\&= ')}" : "#$1#$2 = #{$3.gsub(/\n[\s\t]*/, '\&= ')}"
  end
  self
end

#replace_erb_exec_tagObject



24
25
26
27
# File 'lib/erb_to_slim/engine.rb', line 24

def replace_erb_exec_tag
  gsub!(erb_exec_tag) { "- #$1".gsub(/\n[\s\t]*/, '\&- ') }
  self
end

#replace_html_tagObject



19
20
21
22
# File 'lib/erb_to_slim/engine.rb', line 19

def replace_html_tag
  gsub!(html_tag) { $4.empty? ? "#$1#$2#$3" : "#$1#$2#$3 #$4" }
  self
end

#replace_string_literalObject



36
37
38
39
# File 'lib/erb_to_slim/engine.rb', line 36

def replace_string_literal
  gsub!(string_literal) { $2.nil? ? "#$1| #$2#$3" : $& }
  self
end

#replace_tag_with_classObject



46
47
48
49
# File 'lib/erb_to_slim/engine.rb', line 46

def replace_tag_with_class
  gsub!(tag_with_class) { $1 == 'div' ? ".#{$4.tr(' ', '.')}#$2#$5" : "#$1.#{$4.tr(' ', '.')}#$2#$5" }
  self
end

#replace_tag_with_idObject



41
42
43
44
# File 'lib/erb_to_slim/engine.rb', line 41

def replace_tag_with_id
  gsub!(tag_with_id) { $1 == 'div' ? "\##$4#$2#$5" : "#$1\##$4#$2#$5" }
  self
end