class ERBLint::Linters::ArgumentMappers::SystemArguments
Maps element attributes to system arguments.
def attr_name
def attr_name attribute.name end
def initialize(attribute)
def initialize(attribute) @attribute = attribute @erb_helper = Helpers::ErbBlock.new end
def to_args
def to_args if attribute.erb? _, _, code_node = *attribute.node raise ConversionError, "Cannot convert erb block" if code_node.nil? code = code_node.loc.source.strip m = code.match(TEST_SELECTOR_REGEX) raise ConversionError, "Cannot convert erb block" if m.blank? { test_selector: m[:selector].tr("'", '"') } elsif attr_name == "data-test-selector" { test_selector: erb_helper.convert(attribute) } elsif attr_name.start_with?(*STRING_PARAMETERS) { "\"#{attr_name}\"" => erb_helper.convert(attribute) } else raise ConversionError, "Cannot convert attribute \"#{attr_name}\"" end end