Module: ErbToSlim::Pattern
- Included in:
- Engine
- Defined in:
- lib/erb_to_slim/pattern.rb
Instance Method Summary collapse
- #close_tag ⇒ Object
- #erb_eval_tag ⇒ Object
- #erb_exec_tag ⇒ Object
- #html_tag ⇒ Object
- #html_tags_array ⇒ Object
- #html_tags_list ⇒ Object
- #indentation ⇒ Object
- #js_tag ⇒ Object
- #multiline_string_which_not_match(str) ⇒ Object
- #string_literal ⇒ Object
- #tag_with_class ⇒ Object
- #tag_with_id ⇒ Object
Instance Method Details
#close_tag ⇒ Object
31 32 33 |
# File 'lib/erb_to_slim/pattern.rb', line 31 def close_tag /\s*(<% *end *-?%>|(@ )?<\/\w+>)$/ end |
#erb_eval_tag ⇒ Object
39 40 41 |
# File 'lib/erb_to_slim/pattern.rb', line 39 def erb_eval_tag /^(#{indentation})(#{html_tags_list})? *<%=\s*(#{multiline_string_which_not_match('<%=')})\s*-?%>$/ end |
#erb_exec_tag ⇒ Object
27 28 29 |
# File 'lib/erb_to_slim/pattern.rb', line 27 def erb_exec_tag /<%(?!=)-?\s*((?m:.*?))\s*-?%>/ end |
#html_tag ⇒ Object
35 36 37 |
# File 'lib/erb_to_slim/pattern.rb', line 35 def html_tag /^(#{indentation})<(\w+)(.*?) *(?<!%)\/?> *(.*)?/ end |
#html_tags_array ⇒ Object
5 6 7 8 |
# File 'lib/erb_to_slim/pattern.rb', line 5 def ||= File.readlines(File.('../html_tag_list.txt', __FILE__)) .reject {|line| line =~ /^#|^$/ }.map(&:chomp) end |
#html_tags_list ⇒ Object
10 11 12 |
# File 'lib/erb_to_slim/pattern.rb', line 10 def ||= .join('|') end |
#indentation ⇒ Object
14 15 16 |
# File 'lib/erb_to_slim/pattern.rb', line 14 def indentation /[\s\t]*+/ end |
#js_tag ⇒ Object
23 24 25 |
# File 'lib/erb_to_slim/pattern.rb', line 23 def js_tag /<script *(type="text\/javascript")? *>(#{multiline_string_which_not_match('<script')})<\/script>/ end |
#multiline_string_which_not_match(str) ⇒ Object
18 19 20 21 |
# File 'lib/erb_to_slim/pattern.rb', line 18 def multiline_string_which_not_match(str) str_escaped = str.gsub(/[!<>=?]/, '\\\\\&') /(?:.(?!#{str_escaped}))*?/m end |
#string_literal ⇒ Object
43 44 45 |
# File 'lib/erb_to_slim/pattern.rb', line 43 def string_literal /^(#{indentation})((?:#{html_tags_list}|\||-|=|\#|@))?\b *(.*)$/ end |
#tag_with_class ⇒ Object
51 52 53 |
# File 'lib/erb_to_slim/pattern.rb', line 51 def tag_with_class /([\w#]+)(.*?) *class *= *(["'])(.*?)\3(.*?) *$/ end |
#tag_with_id ⇒ Object
47 48 49 |
# File 'lib/erb_to_slim/pattern.rb', line 47 def tag_with_id /(\w+)(.*?) *id *= *(["'])(.*?)\3(.*?) *$/ end |