Class: A11y::Lint::ErbRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/a11y/lint/erb_runner.rb

Overview

Parses ERB templates and checks them against accessibility rules.

Constant Summary collapse

ERB_TAG =
/<%.*?%>/m
ERB_OUTPUT_TAG =
/<%=\s*(.*?)\s*-?%>/m
ERB_OUTPUT_MARKER =
"A11Y_LINT_ERB_OUTPUT"
VOID_ELEMENTS =
%w[
  area base br col embed hr img input
  link meta param source track wbr
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(rules) ⇒ ErbRunner

Returns a new instance of ErbRunner.



17
18
19
# File 'lib/a11y/lint/erb_runner.rb', line 17

def initialize(rules)
  @rules = rules
end

Instance Method Details

#run(source, filename:) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/a11y/lint/erb_runner.rb', line 21

def run(source, filename:)
  @filename = filename
  @offenses = []

  check_html_nodes(source)
  check_erb_output_tags(source)

  @offenses
end