module ErbToSlim::Pattern

Public Instance Methods

close_tag() click to toggle source
# File lib/erb_to_slim/pattern.rb, line 30
def close_tag
  /\s*(<% *end *-?%>|(@ )?<\/\w+>)$/
end
erb_eval_tag() click to toggle source
# File lib/erb_to_slim/pattern.rb, line 38
def erb_eval_tag
  /^(#{indentation})(#{html_tags_list})? *<%=\s*(#{multiline_string_which_not_match('<%=')})\s*-?%>$/
end
erb_exec_tag() click to toggle source
# File lib/erb_to_slim/pattern.rb, line 26
def erb_exec_tag
  /<%(?!=)-?\s*((?m:.*?))\s*-?%>/
end
html_tag() click to toggle source
# File lib/erb_to_slim/pattern.rb, line 34
def html_tag
  /^(#{indentation})<(\w+)(.*?) *(?<!%)\/?> *(.*)?/
end
html_tags_array() click to toggle source
# File lib/erb_to_slim/pattern.rb, line 4
def html_tags_array
  @html_tags_array ||= File.readlines(File.expand_path('../html_tag_list.txt', __FILE__))
    .reject {|line| line =~ /^#|^$/ }.map(&:chomp)
end
html_tags_list() click to toggle source
# File lib/erb_to_slim/pattern.rb, line 9
def html_tags_list
  @html_tags_list ||= html_tags_array.join('|')
end
indentation() click to toggle source
# File lib/erb_to_slim/pattern.rb, line 13
def indentation
  /[\s\t]*+/
end
js_tag() click to toggle source
# File lib/erb_to_slim/pattern.rb, line 22
def js_tag
  /<script *(type="text\/javascript")? *>(#{multiline_string_which_not_match('<script')})<\/script>/
end
multiline_string_which_not_match(str) click to toggle source
# File lib/erb_to_slim/pattern.rb, line 17
def multiline_string_which_not_match(str)
  str_escaped = str.gsub(/[!<>=?]/, '\\\\\&')
  /(?:.(?!#{str_escaped}))*?/m
end
string_literal() click to toggle source
# File lib/erb_to_slim/pattern.rb, line 42
def string_literal
  /^(#{indentation})((?:#{html_tags_list}|\||-|=|\#|@))?\b *(.*)$/
end
tag_with_class() click to toggle source
# File lib/erb_to_slim/pattern.rb, line 50
def tag_with_class
  /([\w#]+)(.*?) *class *= *(["'])(.*?)\3(.*?) *$/
end
tag_with_id() click to toggle source
# File lib/erb_to_slim/pattern.rb, line 46
def tag_with_id
  /(\w+)(.*?) *id *= *(["'])(.*?)\3(.*?) *$/
end