lib/haml_lint/tree/tag_node.rb
def attributes_source
      @attr_source ||=
        begin
          _explicit_tag, static_attrs, rest = source_code
            .scan(/\A\s*(%[-:\w]+)?([-:\w\.\#]*)(.*)/m)[0]

          attr_types = {
            '{' => [:hash, %w[{ }]],
            '(' => [:html, %w[( )]],
            '[' => [:object_ref, %w[[ ]]],
          }

          attr_source = { static: static_attrs }
          while rest
            type, chars = attr_types[rest[0]]
            break unless type # Not an attribute opening character, so we're done

            # Can't define multiple of the same attribute type (e.g. two {...})
            break if attr_source[type]

            attr_source[type], rest = Haml::Util.balance(rest, *chars)
          end

          attr_source
        end
    end
# Returns the source code for the static and dynamic attributes
# of a tag.
#
# @example For `%tag.class{ id: 'hello' }(lang=en)`, this returns:
#   { :static => '.class', :hash => " id: 'hello' ", :html => "lang=en" }
#
# @return [Hash]
Returns the source code for the static and dynamic attributes
of a tag.
Returns the source code for the static and dynamic attributes of a tag .
def attributes_source
      @attr_source ||=
        begin
          _explicit_tag, static_attrs, rest = source_code
            .scan(/\A\s*(%[-:\w]+)?([-:\w\.\#]*)(.*)/m)[0]
          attr_types = {
            '{' => [:hash, %w[{ }]],
            '(' => [:html, %w[( )]],
            '[' => [:object_ref, %w[[ ]]],
          }
          attr_source = { static: static_attrs }
          while rest
            type, chars = attr_types[rest[0]]
            break unless type 
            break if attr_source[type]
            attr_source[type], rest = Haml::Util.balance(rest, *chars)
          end
          attr_source
        end
    end
def attributes_source @attr_source ||= begin _explicit_tag , static_attrs , rest = source_code . scan ( / \A \s *(%[-: \w ]+)?([-: \w \. \# ]*)(.*) /m ) [ 0 ] attr_types = { '{' => [ :hash , %w[ { } ] ] , '(' => [ :html , %w[ ( ) ] ] , '[' => [ :object_ref , %w[ [ ] ] ] , } attr_source = { static : static_attrs } while rest type , chars = attr_types [ rest [ 0 ] ] break unless type break if attr_source [ type ] attr_source [ type ] , rest = Haml :: Util . balance ( rest , * chars ) end attr_source end end
Returns the source code for the static and dynamic attributes
of a tag.
Returns the source code for the static and dynamic attributes of a tag .
# Not an attribute opening character, so we're done # Can't define multiple of the same attribute type (e.g. two {...})
None
Hash
example
None