Module: RuVim::Lang::Erb

Defined in:
lib/ruvim/lang/erb.rb

Constant Summary collapse

ERB_COMMENT_RE =
/<%#.*?%>/
ERB_TAG_RE =
/<%[=\-]?|[-%]?%>/

Class Method Summary collapse

Class Method Details

.color_columns(text) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ruvim/lang/erb.rb', line 11

def color_columns(text)
  cols = {}

  # First apply HTML highlighting as base
  Html.color_columns(text).each { |k, v| cols[k] = v }

  # ERB delimiters (<%= %> <% %> <%- -%>)
  Highlighter.apply_regex(cols, text, ERB_TAG_RE, "\e[35m", override: true)

  # ERB comment tags override everything (including delimiters)
  Highlighter.apply_regex(cols, text, ERB_COMMENT_RE, Highlighter::COMMENT_COLOR, override: true)

  cols
end