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
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.



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

def initialize(rules)
  @rules = rules
end

Instance Method Details

#run(source, filename:) ⇒ Object



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

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

  check_html_nodes(source)
  check_erb_output_tags(source)

  @offenses
end